akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 500010;
//const int MAXM = 100010;
const int MAXK = 30;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int B = 31;
const int MOD = 1000000007;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return y%4 == 0 && y%100 != 0 || y%400 == 0;
}

int n, m;
//int a[MAXN];

string a[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

void solve()
{
	/*
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	*/
	int d;
	cin >> d;
	string s;
	cin >> s;
	for (auto c : s)
		putchar((c-'A'+d)%26+'A');
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (U == S) A--;
    else B--;
    cout << A << " " << B  << endl;
    return 0;
}

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

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

  vector<vector<ll>> cnt(10, vector<ll>(10, 0));

  for (ll i = 1; i <= n; i++) {
    ll last = i % 10;
    if (last == 0) continue;

    ll first = i;
    while (first >= 10) {
      first /= 10;
    }

    cnt[last][first]++;
  }

  ll ans = 0;
  for (ll i = 0; i < 10; i++) {
    for (ll j = 0; j < 10; j++) {
      ans += cnt[i][j] * cnt[j][i];
    }
  }

  cout << ans << endl;
}


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

int main() {
	// your code goes here
	int n,x,t;
	cin>>n>>x>>t;
	if(n <=x){
	    cout<<t<<endl;
	    return 0;
	}
	int num;
	if(n%x == 0){
	    num=(n/x);
	}else{
	    num=(n/x) + 1;
	}
	cout<<num*t<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>

int main(){
	std::string s;
  	std::cin>>s;
  	int counter=0;
  		if(s[0]=='1')++counter;
  		if(s[1]=='1')++counter;
  		if(s[2]=='1')++counter;
  std::cout<<counter;
  
  
}


Measured memory_bytes: 3104
n = int(input())
arr = list(map(int, input().split()))

#arr：最小公倍数の対象とする配列
MOD = 10**9 + 7
def lcm(arr):
    primes = {}
    for val in arr:
        p = 2
        while p * p <= val:
            if val % p == 0:
                cnt = 0
                while val % p == 0:
                    cnt += 1
                    val //= p
                if p not in primes:
                    primes[p] = cnt
                else:
                    primes[p] = max(cnt, primes[p])
            p += 1
     
        if val != 1:
            if val not in primes:
                primes[val] = 1
    lcma = 1
    for p in primes:
        lcma = lcma * pow(p, primes[p], MOD) 
    return lcma

b = lcm(arr)

ans=0
for i in range(n):
    ans+=(b//arr[i])

print(ans%MOD)


Measured memory_bytes: 44764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int A, B, C;
string s;
int main() {
	cin >> A >> B >> C;
	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());
	int a = v[2] - v[0];
	int b = v[2] - v[1];
	if ((a % 2 == 0 && b % 2 == 0) || (a % 2 != 0 && b % 2 != 0)) {
		cout << (a + b) / 2 << endl;
	}
	else if ((a % 2 == 0 && b % 2 == 1) || (a % 2 != 0&&b % 2 == 0)) {
		cout << (a + b + 1) / 2 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >>s;
    int n = s.length();

    int c = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'p') {
            c = c + 1;
        }
    }

    int ans = n/2 - c;
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int main(){
	int n,m;cin >> n >> m;
	vector<pair<int,int>> v;
	REP(i,n){
		int a,b;
		scanf("%d %d",&a,&b);
		v.PB(MP(a,b));
	}
	
	sort(ALL(v));
	int a,b,c,d;
	int ans;
	
	REP(i,m){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int st = (lower_bound(ALL(v),MP(a,-1000000000)) - v.begin());
		ans = 0;
		for(int i = st;i < n;i++){
			if(v[i].FI > c)break;
			if(v[i].SE >= b && v[i].SE <= d)ans++;
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  long long n;
  long long ans = 0;
  cin >> n;
  long long x = 10;
  if(n==0 || n==1) cout << 0;
  else if(n%2 != 0) cout << 0;
  else{
    while(n >= x){
      ans += n/x;
      x *= 5;
    }
    
    cout << ans;
  }
  return 0;
}

Measured memory_bytes: 256
#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[i];
  vector<int> cost(n+1,-1);
  cost[0]=cost[1]=0;
  for(int i=2;i<=n;i++)
  {
    vector<int> v;
    for(int j=i-1;j>=i-k && j>0;j--)
      	v.push_back(cost[j]+abs(h[i-1]-h[j-1]));
    sort(v.begin(),v.end());
    cost[i]=v[0];
  }
  cout<<cost[n]<<endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

bool used[31234] = {};

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	vector<int32> res;
	cin >> N;
	int32 in = 1;
	int32 odd = 0, three = 0, sum = 0;
	int32 cnt = 0;
	while(cnt < N-1){
		while(in%2 != 0 && in%3 != 0) in++;

		res.push_back(in);
		used[in] = 1;
		odd += in%2;
		three += in%3;
		sum += in;
		cnt++;
		in++;
	}
	odd = (2-odd%2)%2;
	three = (3-three%3)%3;
	FOR(i, 2 , 30001){
		if(i%2 == odd && i%3 == three && !used[i] && gcd(i, sum) != 1){
			res.push_back(i);
			break;
		}
	}
	sort(all(res));
	REP(i, res.size()){
		cout << res[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 640
var
 s:string;
 k:char;
 i:longint; 
begin
 readln(s);
 k:='C';
 for i:=1 to length(s) do
  begin
   if s[i]=k then begin
                   if k='F' then begin
                                  writeln('Yes');
                                  halt;
                                 end
                            else k:='F'
                  end;
  end;
 writeln('No');
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n,c;
  cin>>n>>c;

  vector<vector<ll>> p(c,vector<ll>(c));
  vector<vector<ll>> q(n,vector<ll>(n));

  rep(i,c) rep(j,c) cin>>p[i][j];
  rep(i,n) {
    rep(j,n) {
      cin>>q[i][j];
      q[i][j]--;
    }
  }

  vector<vector<ll>> r(3,vector<ll>(c));

  rep(i,c){
    ll ze=0,on=0,tw=0;
    rep(j,n){
      rep(k,n){
        if((j+k)%3==0) ze+=p[q[j][k]][i];
        if((j+k)%3==1) on+=p[q[j][k]][i];
        if((j+k)%3==2) tw+=p[q[j][k]][i];
      }
    }
    r[0][i]=ze;
    r[1][i]=on;
    r[2][i]=tw;
  }

  ll ans=INF;
  rep(i,c){
    rep(j,c){
      rep(k,c){
        if(i==j||j==k||k==i) continue;
        chmin(ans,r[0][i]+r[1][j]+r[2][k]);
      }
    }
  }

  cout << ans << endl;
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#";
const ll INF = 1e18L + 5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, w;
	cin>>n>>w;
	vector<ll> s(n);
	vector<ll> val(n);
	for(ll x = 0; x < n; x++)
		cin>>s[x]>>val[x];
	
	ll sum = 0;
	for(ll x = 0; x < n; x++)
		sum+=val[x];
	
	vector<ll> ans(sum+1,INF);
	
	ans[0] = 0;
	for(ll x = 0; x < n; x++)
	{
		//cout<<s[x]<<" : ";
		for(ll y = sum; y>=1; y--)
		{
			if(val[x]<=y)
			{
				ans[y] = min(ans[y], ans[y-val[x]]+s[x]);
			}
			// if(ans[y]==INF)
			// 	cout<<"INF ";
			// else cout<<ans[y]<<" ";
		}
		// cout<<"\n";
	}
	
	for(ll x = sum; x >= 1; x--)
	{
			if(ans[x]<=w)
			{
				cout<<x<<"\n";
				break;
			}
	}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, t, mi = 100000000;
	scanf("%d%d", &n, &t);
	for(int i = 0, j, k; i < n; ++i)
	{
		scanf("%d%d", &j, &k);
		if(k <= t)
		{
			mi = min(mi, j);
		}
	}
	printf(mi == 100000000 ? "TLE\n" : "%d\n", mi);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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


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

ll A, B, C, D;

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

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main() {
  cin >> A >> B >> C >> D;
  
  ll sum = 0;
  ll k = lcm(C, D);
  sum += B / C;
  sum += B / D;
  sum -= B / k;
  sum -= (A - 1) / C;
  sum -= (A - 1) / D;
  sum += (A - 1) / k;
  cout << B - A + 1 - sum << endl;
}


Measured memory_bytes: 256
#アルゴリズム：バブルソート
def BubbleSort(list, number):
    for i in range(0, number):
        for j in range(number-1, i, -1):
            if int(list[j][-1]) < int(list[j-1][-1]):
                list[j], list[j-1] = list[j-1], list[j]
    return list
    
#アルゴリズム：挿入ソート
def SelectionSort(list, number):
    for i in range(0, number):
        min_number = i
        for j in range(i, number):
            if int(list[min_number][-1]) > int(list[j][-1]):
                min_number = j
        list[i], list[min_number] = list[min_number], list[i]
    return list

#安定な出力か判定
def StableProcessing(list_A, list_B):
    if list_A == list_B:
        return "Stable"
    else:
        return "Not stable"


#初期data
input_number = int(input())
input_list_B = list(map(str, input().split()))
input_list_S = list(input_list_B)

#処理の実行
input_list_B = BubbleSort(input_list_B, input_number)
print(" ".join(input_list_B))
print("Stable")
input_list_S = SelectionSort(input_list_S, input_number)
print(" ".join(input_list_S))
print(StableProcessing(input_list_B, input_list_S))



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n, prex, prey, pret, difft, diffxy;
    int t[100005], x[100005], y[100005];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    prex = 0, prey = 0, pret = 0;
    for(int i = 0; i < n; i++) {
        difft = t[i] - pret;
        diffxy = x[i] - prex + y[i] - prey;
        if(diffxy < 0) {
            diffxy *= -1;
        }
        if(difft < diffxy) {
            cout << "No" << endl;
            exit(0);
        }
        if(difft % 2 == 1) {
            if(diffxy % 2 != 1) {
                cout << "No" << endl;
                exit(0);
            }
        } else {
            if(diffxy % 2 != 0) {
                cout << "No" << endl;
                exit(0);
            }
        }
        pret = t[i], prex = x[i], prey = y[i];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool compare(pair<int, int>&a, pair<int, int>&b)
{
	return a.first < b.first;
}
int cb(int number)
{
	return (int)log2(number) + 1;
}
int32_t main()
{
	Raghav();
	int a, b, c, k, cnt = 0;
	cin >> a >> b >> c;
	cin >> k;
	while (a >= b)
	{
		cnt++;
		b *= 2;
	}
	while (b >= c)
	{
		cnt++;
		c *= 2;
	}
	if (cnt > k)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main{
public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	long n=sc.nextLong();
	long a=sc.nextLong();
	long b=sc.nextLong();

	if((b-a)%2==1 && ((a-1)>=(n-b))){
		System.out.println((b-a-1)/2+n-b+1);
	}else if((b-a)%2==1 && ((a-1)<(n-b))){
		System.out.println((b-a-1)/2+a);
	}else if((b-a)%2==0){
		System.out.println((b-a)/2);
}

	
}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> y[i];
    double odp = 0;
    vector<int> p(n);
    for (int i = 0; i < n; ++i)
        p[i] = i;
    do
    {
        vector<int> a(n), b(n);
        for (int i = 0; i < n; ++i)
        {
            a[i] = x[p[i]];
            b[i] = y[p[i]];
        }
        for (int i = 1; i < n; ++i)
            odp += sqrt((a[i] - a[i - 1]) * (a[i] - a[i - 1]) + (b[i] - b[i - 1]) * (b[i] - b[i - 1]));
    } while (next_permutation(p.begin(), p.end()));
    for (double i = 2; i <= n; ++i)
        odp /= i;
    cout << fixed << setprecision(8);
    cout << odp;
    return 0;
}


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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
typedef long double ld;
  
mt19937 rnd(time(0));
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
//#define int __int128
 
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2) {
		cout << "No" << endl;
		exit(0);
	}
	bool ok = 1;
	for (int i = 0; i < n / 2; ++i) {
		ok &= (s[i] == s[i + n / 2]);
	}
	if (ok) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
    
signed main() {
    // freopen("cbarn2.in", "r", stdin);
    // freopen("cbarn2.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 256
while True:
    h,w=map(int,input().split())
    if h==0 and w==0 :
        break
    for i in range(h):
        for j in range(w):
            if (i+j)%2 == 0 :
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7000
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    if(a == b)
    {
        if(b == c)
        {
            printf("1");
        }
        else
        {
            printf("2");
        }
    }
    else
    {
        if(b == c || a == c)
        {
            printf("2");
        }
        else
        {
            printf("3");
        }
    }
    
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

ll fact[200001];
const int mod = 1e9 + 7;

void init() {
    fact[0] = 1;
    for(ll i = 1; i <= 200000; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
}

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll inv(ll x) {
    return mod_pow(x, mod - 2, mod);
}

ll comb(ll n, ll r) {
    return ((fact[n] * inv(fact[n - r])) % mod * inv(fact[r])) % mod;
}

map<int, int> getfact(ll M) {
    map<int, int> fact;
    for(int i = 2; i * i <= M; i++) {
        if (M % i == 0) {
            while(M % i == 0) {
                M /= i;
                fact[i]++;
            }
        }
    }
    if (M > 1) fact[M]++;
    return fact;
}

void solve() {
    init();

    ll N, M;
    cin >> N >> M;

    map<int, int> fact = getfact(M);

    ll ans = 1;
    for(auto && f : fact) {
        ans *= comb(f.second + N - 1, N - 1);
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;


fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N:usize = iter.next().unwrap().parse().unwrap();
    let M:usize = iter.next().unwrap().parse().unwrap();
    let mut E = (0..N).map(|_| HashMap::new()).collect::<Vec<_>>();

    for _ in 0..M{
        let l = iter.next().unwrap().parse::<usize>().unwrap() -1;
        let r = iter.next().unwrap().parse::<usize>().unwrap() -1;
        let d = iter.next().unwrap().parse::<isize>().unwrap();
        E[l].insert(r,d);
        E[r].insert(l,-d);
    }

    let mut ans = true;

    let INF = 1_000_100_000;
    let mut D = (0..N).map(|_| INF).collect::<Vec<_>>();
    for i in 0..N{
        if D[i] != INF {continue;}
        D[i] = 0;
        let mut q = vec![i];
        while q.len()>0{
            let j = q.pop().unwrap();
            let dj = D[j];
            for (&k,&d) in &E[j]{
                if D[k] == INF{
                    D[k] = dj + d;
                    q.push(k);
                } else {
                    ans = ans && ((dj + d) == D[k]);
                }
            }
        }
    }
    println!("{}",if ans {"Yes"} else {"No"});
}

Measured memory_bytes: 96504
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>>
#define CO cout<<
#define EN <<endl
typedef long long ll;
using namespace std;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main() {
	int a, b, c,x; CI a >> b >> c>>x;
	int ans = 0;
	REP(i, c+1) {
		if (i * 50 == x) {
			ans++; continue;
		}
		REP(j, b+1) {
			if (j * 100 + i * 50 == x) {
				ans++; continue;
			}
			REP(k, a+1) {
				if (j * 100 + i * 50 + k * 500 == x) { ans++; continue; }

			}
		}
	}

	CO ans EN;

	return 0;
}

Measured memory_bytes: 256
// 桁ごとに獲得ポイントを計算してDP
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 40;
// const int MAX_N = 6;
int v[MAX_N];

pair<ll, ll> ps[1 << (MAX_N / 2)];
ll a[(int) 1e5 + 1];

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

    ll n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ll copy_a = a[i];
        for (int &e : v) {
            e += (copy_a & 1);
            copy_a /= 2;
        }
    }

    ll n2 = MAX_N / 2;
    for (int i = 0; i < 1 << n2; ++i) {
        ll sw = 0, sv = 0;
        ll w = 1;
        ll base = 1;
        for (int j = 0; j < n2; ++j) {
            if (i >> j & 1) {
                sw += base;
                sv += (n - v[j]) * base;
            } else {
                sv += v[j] * base;
            }
            w *= 2;
            base *= 2;
        }
        ps[i] = make_pair(sw, sv);
    }

    sort(ps, ps + (1 << n2));

    int m = 1;
    for (int i = 1; i < 1 << n2; ++i) {
        if (ps[m - 1].second < ps[i].second) {
            ps[m++] = ps[i];
        }
    }

    ll x = 0;
    ll best_v = 0;
    for (int i = 0; i < 1 << (MAX_N - n2); ++i) {
        ll sw = 0, sv = 0, w = 1 << n2;
        ll base = 1 << n2;
        for (int j = 0; j < MAX_N - n2; ++j) {
            if (i >> j & 1) {
                sw += base;
                sv += (n - v[n2 + j]) * base;
            } else {
                sv += v[n2 + j] * base;
            }
            w *= 2;
            base *= 2;
        }
        if (sw <= k) {
            auto itr = lower_bound(ps, ps + m, make_pair(k - sw, (ll)1e12 + 1)) - 1;
            ll tv = itr->second;
            if (best_v < sv + tv) {
                best_v = sv + tv;
                x = itr->first + sw;
            }
        }
    }

    // x = 9;
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        res += a[i] ^ x;
    }

    cout << res << '\n';
    
    return 0;
}


Measured memory_bytes: 17408
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[200005],b[200005];
int n;

int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%lld",&a[i]);
    }
    int l = 1, r = n,flag = 0;
    for(int i = n;i >= 1;i--){
        if(flag == 0) b[l++] = a[i],flag = 1;
        else b[r--] = a[i],flag = 0;
    }
    for(int i = 1;i <= n;i++){
        printf("%lld ",b[i]);
    }
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = (int)(s.charAt(i) - '0');
		}
		
		int cnt = 0;
		
		int []c = new int [4];
		c[3] = -1;
		
		for(c[0] = 0 ; c[0] <= 9 ; c[0]++) {
			int id = 0;
			for(c[1] = 0 ; c[1] <= 9 ; c[1]++) {
				for(c[2] = 0 ; c[2] <= 9 ; c[2]++) {
					
					for(int i = 0 ; i < n ;i++) {
						if(a[i] == c[id]) {
							id++;
						}
					}
					if(id == 3) {
						cnt++;
					}
					id = 0;
				}
			}
		}
		
		System.out.println(cnt);

	}
}


Measured memory_bytes: 24148
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,a;
int main()
{
	cin>>n;
	bool ok=true;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a%2==0)
		{
			if(a%3!=0 && a%5!=0)
			{
				ok=false;
			}
		}
	}
	if(ok)
	{
		cout<<"APPROVED"<<endl;
	}
	else
	{
		cout<<"DENIED"<<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 a = sc.nextInt();//A
		int b = sc.nextInt();//B
		int c = sc.nextInt();//banme
		int n=0;
		int ans=0;
		for(int i=1;i<=b;i++){
			if(a%i==0&&b%i==0){
				n++;
			}
		}

			c=n-c+1;
			n=0;



			for(int i=1;i<=b;i++){
				if(a%i==0&&b%i==0){
					n++;
					}

				if(n==c){
					ans=i;
					i=b+1;
					}
			}


		System.out.println(ans);

	}}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        int x;
        cin >> x;
        a[x - 1]++;
    }
    sort(a.begin(), a.end());
    vector<int> s(N + 1);
    rep(i, N) s[i + 1] = s[i] + a[i]; // sum of [0, i)

    for (int k = 1; k <= N; k++) {
        int l = 0;
        int r = N / k + 1;
        while (l + 1 < r) {
            int c = (l + r) / 2;
            bool ok = [&](int c) {
                int i = lower_bound(a.begin(), a.end(), c) - a.begin();
                int sum = c * (N - i) + s[i];
                return (sum >= c * k);
            }(c);
            if (ok) l = c; else r = c;
        }
        printf("%d\n", l);
    }
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int count = 0;
  string s;
  cin >> s;
  
  for(int i = 0; i < 3; i++)
  {
    if(s[i] == 'o')
    {
      count++;
    }
  }
  
  cout << 700 + (100*count);
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    ll a, b, c;
    cin >> a >> b >> c;

    ll d = c - a - b;
    cout << (d > 0 && 4 * a * b < d * d ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#define N 100

int main(){
  int i,j,n,tmp,min,count=0,A[N];
  
  scanf("%d",&n);
  for(i=0 ; i<n; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0 ; i<n-1 ; i++){
    min=i;
    for(j=i ; j<n ; j++){
      if(A[j]<A[min])
	min=j;
    }
    if(min != i)count++;
    
    tmp=A[i];
    A[i]=A[min];
    A[min]=tmp;
    
  }
  for(i=0 ; i<n ; i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;


int main(){
  int N; cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  vector<int> dp(N + 10, INF);
  dp[0] = 0;
  for (int i = 0; i < N + 1; ++i){
    chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll X,Y,A,B,C,ans,a[500010],b[500010],c[500010],aa[500010],bb[500010],cc[500010];
bool cmp(ll x,ll y){
	return x>y;
}
int main(){
	ll i,l,r,le,re,mid,mx;
	scanf("%lld%lld%lld%lld%lld",&X,&Y,&A,&B,&C);
	for(i=1;i<=A;i++)scanf("%lld",&a[i]);
	for(i=1;i<=B;i++)scanf("%lld",&b[i]);
	for(i=1;i<=C;i++)scanf("%lld",&c[i]);
	sort(a+1,a+A+1,cmp);
	sort(b+1,b+B+1,cmp);
	sort(c+1,c+C+1,cmp);
	for(i=1;i<=A;i++)aa[i]=aa[i-1]+a[i];
	for(i=1;i<=B;i++)bb[i]=bb[i-1]+b[i];
	for(i=1;i<=C;i++)cc[i]=cc[i-1]+c[i];
	for(i=0;i<=X;i++){
		l=X-i+1;
		if(l>C+1)continue;
		le=1;re=min(Y,C-l+1);mx=0;
		while(le<=re){
			mid=(le+re)/2;
			if(c[l+mid-1]>=b[Y-mid+1])mx=mid,le=mid+1;
			 else re=mid-1;
		}
		ans=max(ans,cc[l+mx-1]+aa[i]+bb[Y-mx]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 19456
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗を求めるらしい
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
	//dominoに借りたやつです
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[n])

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	string s;
	cin >> s;
	string t = s;
	int x = 0, y = 0;
	rep(i, s.size()) {
		if (i % 2 == 0)t[i] = '0';
		else t[i] = '1';
	}
	rep(i, s.size()) {
		if (t[i] != s[i])x++;
	}
	rep(i, s.size()) {
		if (i % 2 == 0)t[i] = '1';
		else t[i] = '0';
	}
	rep(i, s.size()) {
		if (t[i] != s[i])y++;
	}
	cout << min(x, y) << rt;


	please AC;
}

Measured memory_bytes: 512
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A__Placing_Marbles
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(ReadLine());
            int[] n = new int [3];
            int b1 = 0;

             n[0] = a / 100;
            b1 = a % 100;
            n[1] = b1 / 10;
            n[2] = b1 % 10;

            WriteLine("{0}",n[0]+n[1]+n[2]);
            ReadKey();
            


        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, M, p; cin >> N >> M >> p;
	vector<int>as(M),ldis(M),rdis(M);
	for (size_t i = 0; i < M; i++)
	{
		cin >> as[i];
	}
	sort(as.begin(), as.end());
	for (size_t i = 0; i < M; i++)
	{
		ldis[i] = (p + N - as[i]) % N;
		rdis[i] = N - ldis[i];
	}
	int ans = 1e8;
	ans = min(ans, N - *min_element(rdis.begin(), rdis.end()));
	ans = min(ans, N - *min_element(ldis.begin(), ldis.end()));
	for (int i = 0; i < M; ++i) {
		ans = min(ans, ldis[i] * 2 + rdis[(i +M- 1)%M]);
		ans = min(ans, rdis[i] * 2 + ldis[(i +1) % M]);
	}
	cout << ans*100 << endl;
	return 0;
}

Measured memory_bytes: 3252
#include <iostream>
using namespace std;
typedef long long i64;

#define MAX_N 200010
#define INF 300010
int P[MAX_N];
int N;

void Solve()
{
  int ans = 1;
  int minimum = P[0];
  for (int i = 1; i < N; ++i){
    if (minimum > P[i]){
      minimum = P[i];
      ans++;
    }
  }
  cout << ans << endl;
}

void Init()
{
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> P[i];
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int w,h;
	int x,y;
	while(1){
		scanf("%d %d",&h,&w);
		if(w==0 && h==0)
			break;
		for(y=0;y<h;y++){
			for(x=0;x<w;x++)
				if(!y || y==h-1 || !x || x==w-1)
					printf("#");
				else
					printf(".");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

vector<int> pos[200001], cur(200001, 0);

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

    vector<int> c(n);
    for(int i = 0; i < n; i++)  cin >> c[i];

    vector<ll> dp(n, 0);
    dp[0] = 1;
    
    for(int i = 0; i < n; i++)  pos[c[i]].push_back(i);

    for(int i = 0; i < n-1; i++){
        // for(int j = cur[c[i]]+1; j < pos[c[i]].size(); j++){
        //     if(pos[c[i]][j]-pos[c[i]][j-1] == 1)    continue;
        //     dp[pos[c[i]][j]] += dp[i];
        //     dp[pos[c[i]][j]] %= mod;
        // }
        int j = cur[c[i]]+1;
        if(j < pos[c[i]].size() && pos[c[i]][j]-pos[c[i]][j-1] != 1){
            dp[pos[c[i]][j]] += dp[i];
            dp[pos[c[i]][j]] %= mod;
        }
        cur[c[i]]++;
        dp[i+1] += dp[i];
        dp[i+1] %= mod;
    }

    cout << dp[n-1] << endl;

    return 0;
}

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

int main() {
  int i, x;
  i = 1;
  while (true) {
    cin >> x;
    if (x == 0) return 0;
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
}
  

Measured memory_bytes: 1160
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] tree = new int[n];
        int ans = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            tree[i] = sc.nextInt();
        Arrays.sort(tree);
        
        for(int i = 0;i < n-k+1;i++){
            int max = tree[i+k-1] , min = tree[i];
            
            ans = Math.min(ans,max-min);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 52912
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    MODP = 998244353
    N, M, K = mis()
    if N==1:
        print(M)
        return
    fs = factorials_list(N, MODP)
    invs = invs_list(N, fs, MODP)
    ans = 0
    for k in range(K+1):
        p = k # 前と同じ個数
        q = (N-1) - p #違う個数
        perm = fs[p+q] * invs[p] * invs[q]
        t_ans = perm % MODP
        t_ans *= M
        t_ans %= MODP
        t_ans *= pow(M-1, q, MODP)
        t_ans %= MODP
        ans = (ans + t_ans) % MODP
    print(ans)


main()



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

#define for_(i,a,b) for(int i=a;i<b;++i)

int n, a[3];

int main() {
	cin >> n;
	for_(i,0,n) cin >> a[i];
	
	for_(i,1,a[0]+1) {
		bool ok = true;
		for_(j,0,n) ok &= (a[j] % i == 0);
		if (ok) cout << i << endl;
	}
	
	return 0;
}

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

int main(){
    
    int N, X, T, ans;
    cin >> N >> X >> T;
   
    if ( X == 1 ){
        ans = N * T;
    } else {
        ans = ((N - 1) / X + 1) * T;
    }
    
    cout << ans;

    return 0;
}


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

using namespace std;

int counts[128];

int main(void) {
    string s;
    char c;
    int twos = 0;

    cin >> s;
    for (int i = 0; i < 128; i++) {
        counts[i] = 0;
    }
    for (int i = 0; i < 4; i++) {
        c = s[i];
        counts[int(c)]++;
    }
    for (int i = 0; i < 128; i++) {
        if (counts[i] == 2) twos++;
    }
    if (twos == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
    int n; std::string s; std::cin >> n >> s;
    int e = 0, w = 0;
    for (auto c: s) {
        if (c == 'E') {
            e++;
        }
    }

    int m = n;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            e--;
            m = std::min(m, w + e);
        } else {
            m = std::min(m, w + e);
            w++;
        }
    }
    std::cout << m << std::endl;
    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll X;
    cin >> X;
    set<ll> s;
    for (ll i = -1000; i <= 1000; i++) {
        for (ll j = -1000; j <= 1000; j++) {
            ll A = pow(i, 5);
            ll B = pow(j, 5);
            //if (A - B >= 1) s.insert(A - B);
            if (A - B == X) {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    //cout << s.size() << "\n";
    return 0;
}

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

typedef long long LL;
const int N = 2003;
char s[N][N];
int l[N][N]={0}, r[N][N]={0}, o[N][N]={0};
int main()
{
    int n, m, q, a, b, c, d, A, B, C, D;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1; i<=n; ++i)
        scanf("%s",s[i]+1);
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=m; ++j)
        {
            l[i][j] = l[i][j-1] + l[i-1][j] - l[i-1][j-1];
            o[i][j] = o[i][j-1] + o[i-1][j] - o[i-1][j-1];
            r[j][i] = r[j][i-1] + r[j-1][i] - r[j-1][i-1];
            if(s[i][j]=='1')
            {
                ++o[i][j];
                if(s[i][j-1] == '1') ++l[i][j];
                if(s[i-1][j] == '1') ++r[j][i];
            }
        }
    }
    while(q--)
    {
        scanf("%d%d%d%d",&A,&B,&C,&D);
        a = min(A, C);
        b = min(B, D);
        c = max(A, C);
        d = max(B, D);
        int cnt, line;
        cnt = o[c][d] - o[c][b-1] - o[a-1][d] + o[a-1][b-1];
        line = l[c][d] - l[c][b] - l[a-1][d] + l[a-1][b];
        line += r[d][c] - r[b-1][c] - r[d][a] + r[b-1][a];
        printf("%d\n",cnt-line);
    }
    return 0;
}


Measured memory_bytes: 52736
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T= input()
def score(x):
  if x == 'r':
    return P
  elif x == 's':
    return R
  elif x == 'p':
    return S
  else:
    return 0
s = 0
List = [x for x in T]
for t in range(len(T)-K):
  if List[t] == List[t+K]:
    List[t+K] = 'z' 
for y in List:  
  s += score(y)
print(s)
  

Measured memory_bytes: 4212