akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    int before_sum = n*l + n*(n-1)/2;
    long long min = 10000000000000;
    int ans;
    for (int i = 0; i < n; i++) {
      if (abs(l+i) < min) {
          min = abs(l+i);
          ans = before_sum - (l+i);
      }  
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int A,B,V,W,T;
cin >> A >> V >> B >> W >> T;

if(A==B){

	cout << "YES";
	return 0;
}

else if(A>B){
	rep(i,T){

	if(A-V<=B-W){
		cout << "YES";
		return 0;
	}
	A = A-V;
	B = B-W;
	}
}
else{
rep(i,T){

	if(A+V>=B+W){
		cout << "YES";
		return 0;
	}
	A = A+V;
	B = B+W;
	}
}

cout << "NO";









	return 0;

}



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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}


int main(void) 
{	
	int n, k; cin>> n >>k;
	string s; cin>> s;
	s[k-1] = char((s[k-1]-'A') + 'a');
	cout<<s;
	return 0;
} 


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

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    map<string,int> plus,minu;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        plus[s[i]]++;
    }
    cin >> m;
    vector<string> t(m);
    for(int i  = 0; i < m; i++){
        cin >> t[i];
        minu[t[i]]++;
    }
    int ans = 0;
    for(auto itr = plus.begin(); itr != plus.end(); itr++){
        ans = max(ans,plus[itr->first]-minu[itr->first]);
    }
    cout << ans  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
 
int main(){
  LL n,k;
  LL x;
  LL sum = 0;
  cin >> n >> k;
  REP(i,n){
    cin >> x;
    sum += 2 * min(abs(x), abs(x-k));
  }
   
  cout << sum << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	string s;
	cin>>s;
	int n = s.size();
	int ans = 0;
	int cnt = 0;
	rep(i, 0, n)
	{
		if(s[i] == 'R') cnt += 1;
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3608
import sys

def solve():
    input = sys.stdin.readline
    N, L = map(int, input().split())
    A = [int(a) for a in input().split()]
    for i in range(N - 1):
        if A[i] + A[i+1] >= L:
            print("Possible")
            for k in range(i): print(k + 1)
            for k in reversed(range(i + 1, N - 1)): print(k + 1)
            print(i + 1)
            break
    else: print("Impossible")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14072
import math
x = int(input())
limit = math.ceil(math.sqrt(x))
min_diff = x - 1
for b in range(2, limit):
  temp_b = b
  while temp_b <= x:
    temp_b *= b
  bp = int(temp_b / b)
  if bp == x:
    print(x)
    exit()
  elif x - bp < min_diff:
    min_diff = x - bp
print(x - min_diff)



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

#define SZ(x) ((int)(x).size())
#define FOR(i, j, n) for (int i(j); i < (n); ++i)
#define FORR(v, c) for (auto &v : (c))
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

typedef	vector<int>	vi;
typedef vector<long long>	vl;
typedef	long long ll;

void solve(void)
{
	ll N, M;
	read2(N,M);
	ll sum(0);
	while (M--)
	{
		ll x; read(x); sum += x;
	}
	ll ans = N-sum;
	if (ans < 0) ans = -1;
	pnl(ans);
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int __t(1);	
	while (__t--)
		solve();
}



Measured memory_bytes: 3652
require 'prime'
MOD = 1_000_000_007
io = STDIN
n,m=io.gets.split.map(&:to_i)
def mul(range)
  range.to_a.inject(:*)
end
def comb(i,j)
  if i<2*j
    ret=comb(i,i-j)
  else
    ret=mul((i-j+1)..i)/mul(1..j)
  end
end
if n==1
  puts 1
else
  puts m.prime_division
        .map{|pr,ct|ct}
        .inject(1){|s,b|comb(b+n-1,b)*s%MOD}
end


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
 

int n;
long long s, r;
   
int main ( void )
{
    ios::sync_with_stdio(false);
    cin.tie(0);   
    cin >> n;
	vector < long long > a ( n );
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a [ i ];
        s ^= a [ i ];
    } //前缀 
    int number = 0;
    for ( int k = 60 - 1 ; k >= 0 ; k--) {
        long long l = 1LL << k; //long long int 
        if ( s & l ) continue;//比较i位上面的为1的是奇数还是偶数，奇数忽略，因为无论怎么划分两部分异或和在i位上都是一个1一个0 
        for ( int i = number ; i < n; i++ ) {
            if ( a [ i ] & l ) { //考虑偶数个1位如何构造最大,高位比低位重要 
                long long t = a [ i ];
                for ( int j = i + 1 ; j < n ; j++ ) {
                    if ( a [ j ] & l ) {
                        a [ j ] ^= t;
                    }
                }
                swap ( a [ number++ ] , a [ i ] );//a [ i ]用过了 
                if ( !( r & l ) ) r ^= t;
                break;
            }
        }
    }
	//r构造了一个能为1就为1的数
	s = r ^ s;
	r = s + r;
    cout << r << endl;

    return 0;
}

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

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

    vector<int> A(N);
    rep(i,0,N-1) {
        int tmp;
        cin >> tmp;
        A[tmp - 1]++;
    }

    for (auto &&a : A) {
        cout << a << endl;
    }
}


Measured memory_bytes: 4024
i = 1
while i <= 9:
    name_i,a_i,b_i = map(str,input().split())
    a_i = int(a_i)
    b_i = int(b_i)
    x = a_i + b_i
    y = a_i * 200 + b_i * 300
    print(name_i,x,y)
    i += 1
    


Measured memory_bytes: 5588
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,a,b;

signed main(){
	cin>>n>>a>>b;
	int d=b-a-1;
	if(d%2==1) return printf("%lld\n",(b-a)/2),0;
	printf("%lld\n",min(a-1,n-b)+(int)((b-a-1)/2)+1);
	return 0;
}

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

int main(int argc, char const* argv[]) {
    int n;
    cin >> n;
    vector<int> dt(n + 1, 9999999);
    vector<int> vs({1, 6, 9});
    dt[0] = 0;
    for (int i = 0; i <= n; ++i) {
        for (auto v : vs) {
            int j = 1;
            while (true) {
                if (v == 1 && j > 1) {
                    break;
                }
                int val = pow(v, j);
                if (i - val >= 0) {
                    dt[i] = min(dt[i - val] + 1, dt[i]);
                } else {
                    break;
                }
                j++;
            }
        }
    }
    cout << dt[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  int n;
  int flag;
  vector<int> prime(0);
  cin>>n;

  //int prime[55556];

  for(int i=2;i<=55555;++i ) {
    flag = 0;
    for(int j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }

    if( flag==0 ){
      prime.push_back(i);
    }
      //printf("%d ", i);
  }

  //for(int x:prime) cout << x << endl;
  int p_cnt=0;
  for(int x:prime){
    if(x==2){
      cout << x << endl;
      p_cnt++;
      if(p_cnt>=n) break;
    }
    else if(x%10 == 7){
      cout << x << endl;
      p_cnt++;
      if(p_cnt>=n) break;      
    }
  }

  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> b;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        int c;
        cin >> c;
        b.emplace_back(c, i);
    }
    sort(b.begin(), b.end());
    int sum = 0;
    for(int i = 0; i < n; i++){
        auto p = b[i];
        sum += a[p.second];
        if(sum > p.first){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int H,W;
  scanf("%d%d",&H,&W);
  int i,j;
  char s[H][W];
  for(i=0;i<H;i++){
    scanf("%s",s[i]);
  }
  int flag=0;
  for(i=1;i<H-1;i++){
    for(j=1;j<W-1;j++){
      if(s[i][j]=='#'&& s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j+1]=='.' && s[i][j-1]=='.'){
	flag=1;
      }
    }
  }
  
  for(j=1;j<W-1;j++){
    if(s[0][j]=='#' && s[1][j]=='.' && s[0][j+1]=='.' && s[0][j-1]=='.'){
      flag=1;
    }
  }
  for(j=1;j<W-1;j++){
    if(s[H-1][j]=='#' && s[H-2][j]=='.' && s[H-1][j+1]=='.' && s[H-1][j-1]=='.'){
      flag=1;
    }
  }
  for(i=1;i<H-1;i++){
    if(s[i][0]=='#' && s[i+1][0]=='.' && s[i-1][0]=='.' && s[i][1]=='.'){
      flag=1;
    }
  }
  for(i=1;i<H-1;i++){
    if(s[i][W-1]=='#' && s[i+1][W-1]=='.' && s[i-1][W-1]=='.' && s[i][W-2]=='.'){
      flag=1;
    }
  }
  if(s[0][0]=='#' && s[1][0]=='.' && s[0][1]=='.'){flag=1;}
  if(s[0][W-1]=='#' && s[1][W-1]=='.' && s[0][W-2]=='.'){flag=1;}
  if(s[H-1][0]=='#' && s[H-1][1]=='.' && s[H-2][0]=='.'){flag=1;}
  if(s[H-1][W-1]=='#' && s[H-1][W-2]=='.' && s[H-2][W-1]=='.'){flag=1;}

  if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
    
	  


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

int main(){
  ll K,sum=0;
  cin >>K;
  rep(i,K){
    rep(j,K){
      rep(k,K){
        int t = gcd(i,gcd(j,k));
        sum += t;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
import numpy as np
S = input()
count = 0
for i in np.arange(0, len(S), 2):
    if S[i] == "L":
        count += 1
        
for i in np.arange(1, len(S), 2):
    if S[i] == "R":
        count += 1

if count == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String args[]) throws Exception {
        String[] tokens = br.readLine().split(" ");
        int n = Integer.parseInt(tokens[0]);
        int k = Integer.parseInt(tokens[1]);
        tokens = br.readLine().split(" ");
        int[] nums = new int[n];
        for(int i=0;i<n;i++){
            nums[i] = Integer.parseInt(tokens[i]);
        }
        solve(nums,k);
        for(int i=0;i<nums.length;i++){
            System.out.print(nums[i]+" ");
        }

    }


    private static void solve(int[] nums,int k){
        int[] updates = new int[nums.length];
        while(k-->0){
            for(int i=0;i<nums.length;i++){
                update(updates,i-nums[i],i+nums[i],1);
            }
            fill(updates,nums);
            Arrays.fill(updates,0);
            if(terminate(nums))
                return;
        }
    }

    private static void update(int[] updates,int left,int right,int val){
        left = Math.max(0,left);
        updates[left]+=val;
        if(right+1<updates.length)
            updates[right+1]-=val;
    }
    private static void fill(int[] updates,int[] nums){
        for(int i=0;i<updates.length;i++){
            updates[i]=updates[i]+(i-1>=0 ? updates[i-1] : 0);
            nums[i] = updates[i];
        }
    }

    private static boolean terminate(int[] nums){
        for(int i=0;i<nums.length;i++){
            if(nums[i]==nums.length)
                continue;
            return false;
        }
        return true;
    }
}

Measured memory_bytes: 60600
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	setprecision(12);
	int n;
	vector<double> x, y;
	double ans=0;

	cin>> n;
	x.resize(n);
	y.resize(n);
	for(int i=0;i<n;i++) cin>> x[i] >> y[i];

	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			ans += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
		}
	}
	cout << fixed << setprecision(10) << ans/(n*(n-1)/2)*(n-1) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
const ll inf=(ll)1e15;
int u[N],v[N],a[2][N];
ll dis[2][N];
vi ad[N];
priority_queue<pair<ll,int> > pq;
void dijkstra(int ind,int s)
{
  rep(i,1,N) dis[ind][i]=inf;
  dis[ind][s]=0;
  pq.push(mp(0,s));
  while(!pq.empty())
    {
      auto x=pq.top();
      pq.pop();
      if(x.fi>-dis[ind][x.se]) continue;
      for(int idx:ad[x.se])
	{
	  int v1=(u[idx]^v[idx]^x.se);
	  if(dis[ind][v1]>dis[ind][x.se]+a[ind][idx])
	    {
	      dis[ind][v1]=dis[ind][x.se]+a[ind][idx];
	      pq.push(mp(-dis[ind][v1],v1));
	    }
	}
    }
}
ll ans[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  rep(i,1,m+1)
    {
      cin>>u[i]>>v[i]>>a[0][i]>>a[1][i];
      ad[u[i]].pb(i);
      ad[v[i]].pb(i);
    }
  dijkstra(0,s);
  dijkstra(1,t);
  multiset<ll> tmp;
  rep(i,1,n+1)
    {
      ans[i]=inf-dis[0][i]-dis[1][i];
      tmp.insert(ans[i]);
    }
  rep(i,1,n+1)
    {
      cout<<*tmp.rbegin()<<endl;
      tmp.erase(tmp.find(ans[i]));
    }
  return 0 ;
}


Measured memory_bytes: 16372
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
char s[SZ]; int n,m,l[SZ],r[SZ],g[SZ],rs[SZ];
set<pii> ss;
int ch[SZ][2],dis[SZ],v[SZ],an=0;
int merge(int a,int b)
{
    if(!a||!b) return a+b;
    if(v[a]>v[b]) swap(a,b);
    ch[a][1]=merge(ch[a][1],b);
    if(dis[ch[a][0]]<dis[ch[a][1]]) swap(ch[a][0],ch[a][1]);
    if(!ch[a][1]) dis[a]=0;
    else dis[a]=dis[ch[a][1]]+1;
    return a;
}
int pop(int a)
{
    int t=merge(ch[a][0],ch[a][1]);
    ch[a][0]=ch[a][1]=dis[a]=0;
    return t;
}
int R[SZ];
int bb[SZ];
void edt(int x,int y)
{
	for(;x<=SZ;x+=x&-x) (bb[x]+=y)%=26;
}
int qry(int x)
{
	int s=0;
	for(;x>=1;x-=x&-x) (s+=bb[x])%=26;
	return s;
}
void add(int l,int r,int v)
{
	edt(l,v); edt(r+1,(26-v)%26);
}
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	scanf("%d",&m);
	int dv=n/2;
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",l+i,r+i);
		if(l[i]>n+1-r[i]) l[i]=n+1-l[i],r[i]=n+1-r[i],swap(l[i],r[i]);
		if(r[i]>dv) r[i]=n-r[i];
		if(l[i]>r[i]) continue;
		++an; v[an]=r[i]; rs[l[i]]=merge(rs[l[i]],an);
	}
	for(int i=1;i<=dv;++i)
	{
		if(!rs[i]) continue;
		R[i]=v[rs[i]];
		while(rs[i]&&v[rs[i]]==R[i]) rs[i]=pop(rs[i]);
		rs[R[i]+1]=merge(rs[R[i]+1],rs[i]); rs[i]=0;
	}
	for(int i=1;i<=dv;++i)
	{
		g[i]=s[i]-s[n+1-i];
		while(g[i]<0) g[i]+=26;
		while(g[i]>=26) g[i]-=26;
		add(i,i,g[i]);
		int x=qry(i);
		if(R[i]) add(i,R[i],(26-x)%26);
	}
	for(int i=1;i<=dv;++i)
		if(qry(i)) {puts("NO");return 0;}
	puts("YES");
}


Measured memory_bytes: 23040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	ans = max(ans,a*10+b+c);
	ans = max(ans,c*10+b+a);
	ans = max(ans,b*10+a+c);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  string s;
  cin>>s;
  int n=s.size();
  int cnt=0;
  for(int i=0;i<n/2;i++){
    if(s[n-1-i]!=s[i]){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int a, b;
  
  for(int i = 0; i < s.size(); i ++){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }

  for(int i = s.size(); i > 0; --i ){
    if(s[i-1] == 'Z'){
      b = i-1;
      break;
    }
  }
  cout << b - a + 1 << endl;
}
        

Measured memory_bytes: 640
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    ll n;scanf("%lld",&n);
    vector<ll> a(n);
    for(int i = 0;i < n;i++)scanf("%lld",&a[i]);

    vector<ll> c(n+1,0);
    for (int i = 0; i < n; ++i)
    {
        c[i+1] = c[i]+a[i];
    }
    ll ans = LONG_MAX;
    for(ll i = 1;i <= n-1;i++){
        ans = min(ans,abs((c[n]-c[i]) - c[i]));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

double dist[1100][1100];
double DP[1100][1100];

int main(){
	
	int N;
	cin >> N;
	
	double x[1100], y[1100];
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			double dx = x[j] - x[i];
			double dy = y[j] - y[i];
			dist[i][j] = sqrt(dx * dx + dy * dy);
		}
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			DP[i][j] = INF;
		}
	}
	
	DP[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++){
			DP[i][i + 1] = min(DP[i][i + 1], DP[j][i] + dist[j][i + 1]);
		}
		for(int j = i + 2; j < N; j++){
			DP[i][j] = DP[i][j - 1] + dist[j - 1][j];
		}
	}
	/*
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << DP[i][j] << " ";
		}
		cout << endl;
	}
	*/
	double ans = INF;
	for(int i = 0; i < N; i++){
		ans = min(ans, DP[i][N - 1] + dist[i][N - 1]);
	}
	
	printf("%.8f\n", ans);
	
	return 0;
}


Measured memory_bytes: 20404
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

const int N=2e5+5;

int n;
int a[N];

namespace S1{
    int c[40];//在这一位上是右儿子的边数
    bool check(int k){
        int len=0;
        memset(c,0,sizeof(c));
        FOR(i,1,n){
            if(a[i]>len){
                FOR(j,len+1,a[i])++c[j];
                len=a[i];
            }else {
                int pos=a[i];
                while(c[pos]==k)--pos;
                if(pos==0)return 0;
                c[pos]++;
                FOR(j,pos+1,30)c[j]=0;//清空
                FOR(j,pos+1,a[i])c[j]++;
                len=a[i];
            }
        }
        return 1;
    }
}
int tot=0;

namespace S2{
    map<int,int> c;
    bool check(int k){
        int len=0;
        c.clear();
        FOR(i,1,n){
            if(a[i]>len){
            }else {
                int pos=a[i];
                while(tot<4e6&&pos&&c[pos]==k-1)--pos,++tot;
                if(pos==0)return 0;
                c[pos]++;
                map<int,int>::iterator it=c.find(pos),i2;
                while(tot<4e6&&(i2=it,++i2,i2!=c.end()))c.erase(i2),++tot;
            }
            len=a[i];
            //if(tot>=1e7)return 0;
            if(tot>=4e6)return 0;
        }
        return 1;
    }
}
int main(){
    scanf("%d",&n);
    FOR(i,1,n)scanf("%d",&a[i]);
    int l=1,r=n+1,mid;
    while(l<r&&tot<4e6)mid=(l+r)>>1,S2::check(mid)?r=mid:l=mid+1;
    if(tot>=4e6){
        FOR(i,1,n)a[i]=min(a[i],30);
        l=1,r=n+1;
        while(l<r)mid=(l+r)>>1,S1::check(mid)?r=mid:l=mid+1;
    }
    printf("%d\n",l);
    return 0;
}


Measured memory_bytes: 108800
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b)
            System.out.println(c);
        else if (b == c)
            System.out.println(a);
        else
            System.out.println(b);
    }
}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import static java.lang.Math.abs;
import static java.lang.Math.min;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    n = in.ni();
    h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = in.ni();
    }
    dp = new Integer[n];
    out.println(recurse(0));
  }
  
  private int n;
  private int[] h;
  private Integer[] dp;
  
  private int recurse(int idx) {
    if (idx == n - 1) return 0;
    
    if (dp[idx] != null) return dp[idx];
    
    int ans = Integer.MAX_VALUE;
    if (idx + 1 < n) ans = min(ans, abs(h[idx + 1] - h[idx]) + recurse(idx + 1));
    if (idx + 2 < n) ans = min(ans, abs(h[idx + 2] - h[idx]) + recurse(idx + 2));
    
    return dp[idx] = ans;
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 51928
#include<iostream>
using namespace std;
int main(){
    int a, b, c, i, cnt;
    cin >> a >> b >> c;
    cnt = 0;

    for(i = a; i <= b; i++){
        if(c % i == 0)  cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll N;
	cin >> N;
	string S;
	cin >> S;
	ll r = 0;
	ll b = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'B')b++;
		else r++;
	}
	if (b < r)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*input
5 5 10
2 5
4 3
2 3
5 5
2 2
5 4
5 3
5 1
3 5
1 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int r[maxn],c[maxn];
set<pii> s;
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int h,w,m;
    cin>>h>>w>>m;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        r[a]++;
        c[b]++;
        s.insert({a,b});
    }
    vector<pii> v;
    REP(i,w){
        v.pb({c[i],i});
    }
    sort(ALL(v));
    reverse(ALL(v));
    int ans=0;
    REP(i,h){
        REP(j,w){
            int x=s.count({i,v[j].s});
            MXTO(ans,r[i]+v[j].f-x);
            if(!x) break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 23824
#include <cstdio>

int main(void)
{
	int *a,i,N,lwbd;
	long long counter=0;
	scanf("%d%d",&N,&lwbd);
	a=new int [N];
	for(i=0;i<N;i++)
		scanf("%d",a+i);

	if(a[0]>lwbd)
	{
		counter=a[0]-lwbd;
		a[0]=lwbd;
	}
	for(i=1;i<N;i++)
	{
		if(a[i-1]+a[i]>lwbd)
		{
			counter+=a[i-1]+a[i]-lwbd;
			a[i]=lwbd-a[i-1];
		}

	}
#if DEBUG
	for(i=0;i<N;i++)
		printf("[%2d]:\t%d\n",i,a[i]);
#endif

	printf("%lld\n",counter);
	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 200020
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

ll num[MAX_N];

ll p[MAX_N];

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

  setComb();

  p[0]=0;
  for(int i=1;i<=N;i++) p[i]=(p[i-1]+inv[i])%MOD;

  ll ans=0;
  ll sum=0;
  for(ll i=0;i<N-1;i++){
      //sum=sum*(i)%MOD;
      //sum=(sum+(i+1))%MOD;
      //sum=sum*fac[i]%MOD;
      //sum=(sum+p[i])%MOD;
      //cout<<i<<" "<<sum<<endl;
      //sum=sum*ifac[i+1]%MOD;
      
      ll res=X[i+1]-X[i];
      res=res*p[i+1]%MOD;
      //res=res*fac[N-1]%MOD;
      //res=res*ifac[i+1]%MOD;
      //cout<<i<<" "<<sum<<" "<<res<<endl;
      ans=(ans+res)%MOD;
  }

  ans=ans*fac[N-1]%MOD;


  cout<<ans%MOD<<endl;


  return 0;
}


Measured memory_bytes: 7552
N = int(input())

S = []
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for _ in range(N):
    S.append(input()) 
   
for i in range(len(S)):
  if S[i] == "AC":
    c0 += 1
  if S[i] == "WA":
    c1 += 1
  if S[i] =="TLE":
    c2 += 1
  if S[i] == "RE":
    c3 +=1
    
print("AC x ", c0)
print("WA x " ,c1)
print("TLE x ", c2)
print("RE x ", c3)
  

Measured memory_bytes: 16320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Point {
  double x, y, z;
  Point(double x, double y, double z): x(x), y(y), z(z) {}
};
double operator*(const Point &p1, const Point &p2) {
  return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z;
}
Point operator+(const Point &p1, const Point &p2) {
  return Point(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z);
}
Point operator-(const Point &p1, const Point &p2) {
  return Point(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z);
}
Point operator*(const double &k, const Point &p) {
  return Point(k * p.x, k * p.y, k * p.z);
}
double dist2(const Point &p1, const Point &p2) {
  return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y) + (p1.z - p2.z) * (p1.z - p2.z);
}
bool solve() {
  int n, m, R;
  cin >> n >> m >> R;
  if (n == 0) return false;
  vector<Point> s;
  vector<double> r(n);
  for(int i=0;i<(n);++i) {
    double x, y, z, nr; cin >> x >> y >> z >> nr;
    s.emplace_back(Point(x, y, z));
    r[i] = nr;
  }
  vector<Point> t;
  vector<double> b(m);
  for(int i=0;i<(m);++i) {
    double x, y, z, nb; cin >> x >> y >> z >> nb;
    t.emplace_back(Point(x, y, z));
    b[i] = nb;
  }
  Point e(0, 0, 0);
  cin >> e.x >> e.y >> e.z;
  vector<bitset<2000>> need(m);
  for(int i=0;i<(m);++i) {
    for(int j=0;j<(n);++j) {
      Point d = t[i] - e;
      double k = ((s[j] * d) - (e * d)) / (d * d);
      Point x = e + k * d;
      bool ok = true;
      if(0 < k && k < 1 && dist2(e, s[j]) > r[j] * r[j] && dist2(t[i], s[j]) > r[j] * r[j]) ok &= dist2(x, s[j]) > r[j] * r[j];
      ok &= (dist2(e, s[j]) > r[j] * r[j]) == (dist2(t[i], s[j]) > r[j] * r[j]);
      need[i][j] = !ok;
    }
  }
  double ma = 0;
  for(int i=0;i<(1<<m);++i) {
    bitset<2000> now;
    for(int j=0;j<(m);++j) {
      if((i>>j)&1) now |= need[j];
    }
    if(now.count() > R) continue;
    double val = 0;
    for(int j=0;j<(m);++j) {
      if((i>>j)&1) {
        val += b[j] / dist2(t[j], e);
      }
    }
    chmax(ma, val);
  }
  cout << ma << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while (solve()) {}
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;

double E[601];
vector<int> d[601];
int N,M; 

double solve(){
    for(int i=0;i<N;i++) E[i]=0;
    for(int i=N-1;i>=1;i--){
        int S=d[i].size();
        if(S>0){
            for(int j=0;j<S;j++){
                E[i]+=E[d[i].at(j)];
            }
            E[i]/=S;
            E[i]+=1;
        }
    }
    return E[1];
}

int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int s,t; cin>>s>>t;
        d[s].push_back(t);
    }

    double ans=solve();

    for(int i=1;i<N;i++){
        while(d[i].size()<2) {i++; if(i==N) break;}
        if(i==N) break;
        int del=0;
        for(int j=1;j<d[i].size();j++) if(E[d[i].at(del)]<E[d[i].at(j)]) del=j;
        int m=d[i].at(del);
        d[i].erase(d[i].begin()+del);
        double x=solve();
        //cout<<i<<' '<<x<<endl;
        ans=min(ans,x);
        d[i].push_back(m);
    }

    cout<<setprecision(10)<<ans<<endl;

    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
bool gem[21][21];
int main() {
    int N;
    while(scanf("%d",&N),N) {
        memset(gem,0,sizeof(gem));
        for(int i=0;i<N;i++) {
            int x,y;
            scanf("%d %d",&x,&y);
            gem[x][y]=1;
        }
        int M;
        int X=10,Y=10;
        int sum=0;
        scanf("%d",&M);
        for(int i=0;i<M;i++) {
            char d[2];
            int l;
            scanf("%s %d",d,&l);
            if(d[0]=='N') {
                for(int i=1;i<=l;i++) if(gem[X][Y+i]) {gem[X][Y+i]=0;sum++;}
                Y+=l;
            }
            if(d[0]=='E') {
                for(int i=1;i<=l;i++) if(gem[X+i][Y]) {gem[X+i][Y]=0;sum++;}
                X+=l;
            }
            if(d[0]=='S') {
                for(int i=1;i<=l;i++) if(gem[X][Y-i]) {gem[X][Y-i]=0;sum++;}
                Y-=l;
            }
            if(d[0]=='W') {
                for(int i=1;i<=l;i++) if(gem[X-i][Y]) {gem[X-i][Y]=0;sum++;}
                X-=l;
            }
        }
        if(sum==N) printf("Yes\n"); else printf("No\n");
     }
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n, m = map(int, input().split())

    n_map, m_map = [], []
    for _ in range(n):
        n_map.append(list(map(int, input().split())))
    for _ in range(m):
        m_map.append(list(map(int, input().split())))

    for st in n_map:
        min_index = 1
        min_val = abs(st[1] - m_map[0][1]) + abs(st[0] - m_map[0][0])
        counter = 1
        for pl in m_map:
            temp = abs(st[1] - pl[1]) + abs(st[0] - pl[0])
            if temp < min_val:
                min_val = temp
                min_index = counter
            counter += 1
        print(min_index)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N, x = inpl()
A = inpl()
ans = sum(A)

for i in range(1, N):
    A = [min(A[j], A[(j-1)%N]) for j in range(N)]
    ans = min(ans, sum(A) + x*i)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cctype>
#include <algorithm>
#include <queue>

using namespace std;

#define M 1000005
#define ll long long

int X, Y, Z, n, _gold, _silver, _bronze;
ll sum, ans, pre_mx[M], suf_mx[M];

struct Person
{
	ll GmB, SmB;
} p[M];

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

inline bool cmp1(Person a, Person b)
{ return a.GmB - a.SmB > b.GmB - b.SmB; }

signed main()
{
	X = read(), Y = read(), Z = read(); n = X + Y + Z;
	for (int i = 1; i <= n; i++)
	{
		_gold = read(), _silver = read(), _bronze = read();
		sum += _bronze; p[i].GmB = _gold - _bronze, p[i].SmB = _silver - _bronze;
	}

	sort(p + 1, p + 1 + n, cmp1);

	priority_queue< ll, vector<ll>, greater<ll> > q;

	for (int i = 1; i <= n; i++)
	{
		pre_mx[i] = pre_mx[i-1] + p[i].GmB; q.push(p[i].GmB);
		if (q.size() > X) pre_mx[i] -= q.top(), q.pop();
	}

	while (!q.empty()) q.pop();

	for (int i = n; i >= 1; i--)
	{
		suf_mx[i] = suf_mx[i+1] + p[i].SmB; q.push(p[i].SmB);
		if (q.size() > Y) suf_mx[i] -= q.top(), q.pop();
	}

	ans = -1e15;	 
	for (int i = X; i <= X + Z; i++)
		ans = max(ans, pre_mx[i] + suf_mx[i+1]);

	cout << sum + ans;

	return 0;
}

Measured memory_bytes: 6700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int n = in.nextInt();
            out.print(n / 2 + (n % 2));
        }

    }
}



Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int A = cin.nextInt();
        int B = cin.nextInt();
        int cnt = 0;
        for (int i = A; i <= B; i++) {
            int n = i;
            int a = n % 10; n /= 10;
            int b = n % 10; n /= 10;
            n /= 10;
            int d = n % 10; n /= 10;
            int e = n % 10;

            if (a == e && b == d) {
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b){
	return b != 0 ? gcd(b, a%b) : a;
}

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

#define N_MAX 310
#define MOD 1000000007

void solv()
{
	lli A, B, K; scanf("%lld%lld%lld", &A, &B, &K);

	//if (K < A){
	//	printf("%lld %lld", A - K, B);
	//}
	//else if (A <= K && K < A + B){
	//	printf("0 %lld", B - (K - A));
	//}
	//else{
	//	printf("0 0");
	//}

	if (K < A){
		printf("%lld %lld\n", A - K, B);
		return;
	}

	if (K >= A + B){
		printf("0 0\n");
		return;
	}
	else{
		B = B - (K - A);
		A = 0;

		printf("%lld %lld\n", A, B);
		return;
	}



	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];

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

    sc.close(); 
    
    int count = 0;

    while (0 < N) {
      N = N - K;
      if (0 < N) {
        N = N + 1;
      }
      count++;
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 50556
#!/usr/bin/env python
# coding: utf-8

# In[11]:


N,M = map(int, input().split())


# In[12]:


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# In[14]:


for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)


# In[ ]:






Measured memory_bytes: 9128
#include<stdio.h>
  int main(void){
    int a,b,sum,sub,pro;
    scanf("%d",&a);
    scanf("%d",&b);

    sum = a+b;
    sub = a-b;
    pro = a*b;

    if(sum > sub){
      if(sum > pro){
        printf("%d",sum);
      }
      else{
        printf("%d",pro);
      }
    }else{
      if(sub>pro){
        printf("%d",sub);
      }else{
        printf("%d",pro);
      }
    }

    return 0;
  }
 

Measured memory_bytes: 128
A,B,H,M = map(int,input().split())
import numpy as np
#print(float(M)/60-float(H)/12)
angle = np.pi*abs(60*H-11*M)/360
x_2 = A**2+B**2-2*A*B*np.cos(angle)
x = np.sqrt(x_2)
print(x)

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

int Psz;
struct PMA{
	int n;
	PMA *next[0x200];
	vector<int> accept;
	PMA() { fill(next, next+0x200, (PMA*)0); }
	PMA(int a)
	{
		n=a;
		fill(next, next+0x200, (PMA*)0);
	}
};

PMA *buildPMA(vector<string>& p, vector<PMA*>& vpma, int size)
{
	Psz=0;
	PMA *root = new PMA(Psz++);
	vpma.push_back(root);
	for(int i=0; i<size; i++)
	{
		PMA* t=root;
		for(int j=0; j<p[i].size(); j++)
		{
			char c=p[i][j];
			if(t->next[c] == NULL)
			{
				t->next[c] = new PMA(Psz++);
				vpma.push_back(t->next[c]);
			}
			t = t->next[c];
		}
	}

	queue<PMA*> Q;
	for(int c = 'A'; c<='Z'; c++)
	{
		if(root->next[c])
		{
			root->next[c]->next[0]=root;
			Q.push(root->next[c]);
		}
		else
		{
			root->next[c] = root;
		}
	}

	while(!Q.empty())
	{
		PMA *t = Q.front(); Q.pop();
		for(int c = 'A'; c<='Z'; c++)
		{
			if(t->next[c])
			{
				Q.push(t->next[c]);
				PMA *r = t->next[0];
				while(!r->next[c]) r = r->next[0];
				t->next[c]->next[0] = r->next[c];
			}
		}
	}

	return root;
}

int match(char t, PMA* v, int &ret)
{
	int r=v->n;

	char c=t;
	while(!v->next[c]) v = v->next[0];
	v = v->next[c];
	r = v->n;
	ret += v->accept.size();

	return r;
}

void makeacpt(PMA* p, int n, string w)
{
	PMA *t = p;
	for(int j=0; j<w.size(); j++)
	{
		char c=w[j];
		if(t->next[c]==NULL) return;
		t = t->next[c];
	}

	for(int i=0; i<t->accept.size(); i++)
		if(t->accept[i]==n) return;

	t->accept.push_back(n);
}

class State
{
public:
	int x,y,pma,c;
	State(int x, int y, int pma, int c)
		:x(x),y(y),pma(pma),c(c)
	{}
};

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

bool v[60][60][60];
char dir[4]={'L', 'U', 'R', 'D'};

int main()
{
	int M,N;
	while(cin >> N >> M, (M||N))
	{
		memset(v,0,sizeof(v));

		int sx,sy;
		char f[90][90];
		for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
		{
			cin >> f[j][i];
			if(f[j][i]=='S')
			{
				sx=j;
				sy=i;
			}
		}

		int P;
		cin >> P;
		vector<string> str;
		for(int i=0; i<P; i++)
		{
			string s;
			cin >> s;
			str.push_back(s);
		}

		vector<PMA*> vpma;
		PMA* root = buildPMA(str,vpma,str.size());
		for(int j=0; j<str.size(); j++)
		for(int i=0; i<Psz; i++)
		{
			PMA* p=vpma[i];
			makeacpt(p,j,str[j]);
		}

		bool g=false;
		queue<State> q;
		q.push(State(sx,sy,0,0));

		while(!q.empty())
		{
			State s=q.front(); q.pop();
			if(v[s.x][s.y][s.pma]) continue;
			v[s.x][s.y][s.pma]=1;

			if(f[s.x][s.y]=='G')
			{
				g=true;
				cout << s.c << endl;
				break;
			}

			for(int i=0; i<4; i++)
			{
				int tx=s.x+dx[i], ty=s.y+dy[i];
				if(tx<0||ty<0||tx>=M||ty>=N) continue;
				if(f[tx][ty]=='#') continue;

				int ret=0;
				int tpma = match(dir[i],vpma[s.pma],ret);

				if(ret!=0) continue;
				if(v[tx][ty][tpma]) continue;

				q.push(State(tx,ty,tpma,s.c+1));


			}

		}

		if(!g) cout << -1 << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s,t;
  int count=0;
  
  cin>>s;
  cin>>t;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]==t[i])
    {
      int count=0;
    }
    else{
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3872