akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (((bit >> i) & 1) > 0)

typedef long long LL;
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a, Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}    // C++14
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };


using namespace std;


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

    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        auto dp = make_v<LL>(N + 10);
        dp[0] = 1;
        FOR(i, 0, N) {
            FOR(j, 1, 4) {
                dp[i + j] += dp[i];
            }
        }

        print(ceil(ceil(dp[N], 10LL), 365LL));
    }


    return 0;
}




Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
#define MAX 50

int main() {
    int N, a, count=0;

    cin >> N;

    for (int i=1; i<=N; i++) {
        cin >> a;
        if (i!=a) count++;
    }

    if (count==2 || count==0) cout << "YES";
    else cout << "NO";

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
	int height, width, i, j, k, count, count2 = 0;
	char **a, **b, **c, buf;
	scanf("%d %d", &height, &width);
	a = (char**)malloc(sizeof(char*)*height);
	for(i = 0; i < height; i++) a[i] = (char*)malloc(sizeof(char)*width);
	buf = getchar();
	for(i = 0; i < height; i++){
		for (j = 0; j < width; j++) {
			scanf("%c", &a[i][j]);
		}
		buf = getchar();
	}

	b = (char**)malloc(sizeof(char*)*height);
	for (i = 0; i < height; i++) b[i] = (char*)malloc(sizeof(char)*width);
	for (i = 0, k = 0; i < height; i++, k++) {
		count = 0;
		for (j = 0; j < width; j++) {
			if (a[i][j] == '#') {
				for (j = 0; j < width; j++) b[k][j] = a[i][j];
				count++;
				break;
			}
		}
		if (count == 0) {
			k--;
			count2++;
		}
	}
	height -= count2;

	c = (char**)malloc(sizeof(char*)*height);
	for (i = 0; i < height; i++) c[i] = (char*)malloc(sizeof(char)*width);

	count2 = 0;
	for (i = 0, k = 0; i < width; i++, k++) {
		count = 0;
		for (j = 0; j < height; j++) {
			if (b[j][i] == '#') {
				for (j = 0; j < height; j++) c[j][k] = b[j][i];
				count++;
				break;
			}
		}
		if (count == 0) {
			k--;
			count2++;
		}
	}
	width -= count2;
	for (i = 0; i < height; i++) {
		for (j = 0; j < width; j++) {
			printf("%c", c[i][j]);
		}
		puts("");
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n";

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){
    

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin>>k;
    k--;
    cout<<a[k]<<"\n";
    
}


/*

// 

*/

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        for(int i = 1;i*i <= n;i++){
            if(i*i <= n){
                max = Math.max(max,i*i);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<queue>

using namespace std;

int main () {
  int K;
  long long int ans;
  queue<long long int> q;
  cin >> K;

  for (int i=1; i<10; i++) {
      q.push((long long int)i);
      continue;
  }
  for (int i=0; i<K; i++) {
    ans = q.front();
    q.pop();
    if (ans % 10 == 0) {
      q.push(ans * 10);
      q.push(ans * 10 + 1);
    } else if (ans % 10 == 9) {
      q.push(ans * 10 + 8);
      q.push(ans * 10 + 9);
    } else {
      q.push(ans * 10 + (ans%10) - 1);
      q.push(ans * 10 + (ans%10));
      q.push(ans * 10 + (ans%10) + 1);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main(){
    int N;
    cin>>N;
    vector<int> cnt(N+1,0);
    vector<int> A(N);
    for(int i=0; i<N-1; i++){
        cin>>A[i];
    }

    for(int i=0; i<N-1; i++){
        cnt[A[i]]++;
    }

    for(int i=1; i<=N; i++){
        cout<<cnt[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
ll n, m;
vector<ll> v[8];
int main()
{
    cin >> n >> m;
    rep(i, n)
    {
        ll x, y, z;
        cin >> x >> y >> z;
        v[0].push_back(x + y + z);
        v[1].push_back(x + y - z);
        v[2].push_back(x - y + z);
        v[3].push_back(x - y - z);
        v[4].push_back(-x + y + z);
        v[5].push_back(-x + y - z);
        v[6].push_back(-x - y + z);
        v[7].push_back(-x - y - z);
    }
    rep(i, 8)
    {
        sort(v[i].begin(), v[i].end(), greater<ll>());
    }
    ll ans = -10000000000000;
    rep(i, 8)
    {
        ll t = 0;
        rep(j, m)
        {
            t += v[i][j];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int main(void){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		int a[100],b[100],dif=0;
		rep(i,n){
			cin>>a[i];
			dif+=a[i];
		}
		rep(i,m){
			cin>>b[i];
			dif-=b[i];
		}
		int first=-1,second=-1,sum=999999;
		rep(i,n){
			rep(j,m){
				if(2*(a[i]-b[j])==dif && sum>a[i]+b[j]){
					first=a[i];
					second=b[j];
					sum=a[i]+b[j];
				}
			}
		}
		if(sum!=999999){
			cout<<first<<" "<<second<<endl;
		}else{
			cout<<-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
n = int(input())
li = []

for i in range(1,32):
    for j in range(2,11):
        x = i**j
        if x <= 1000:
            li.append(x)

li.sort()

for i in range(len(li)):
    if li[i] == n:
        print(n)
        exit()
    elif li[i] > n:
        print(li[i-1])
        exit()

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

int main() {
  int a, b;
  int num;
  int i = 0;
  int count = 0;
  cin >> num;
  
  for (i = 0; i < num; i++){
    cin >> a >> b;
    count += (b - a + 1);
  }

  cout << count << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;
  int l, r, l_m = 0, r_m = n+1;
  rep(i, m){
    cin >> l >> r;
    l_m = max(l_m, l);
    r_m = min(r_m, r);
  }
  cout << max(r_m - l_m + 1, 0) << endl;
}


Measured memory_bytes: 256
n = int(input())
import math
l = []
for i in range(1,n +1):
    for j in range(1,n+1):
        l.append(math.gcd(i,j))
ans = 0
for i in range(1, n+1):
    for j in l:
        ans += math.gcd(j,i)
print(ans)


Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  string S,T;
  cin >>S>>T;
  int N =sz(S);
  bool f = false;
  rep(i,N){
    int che = 0;
   rep(j,N){
     int s = i+j;
	if(s>=N) s %= N;
     if(S[s] == T[j]) che++;
   }
    if(che == N) f = true;
  }
  if(f) out("Yes");
  else out("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n, s;
 
long long sum(long long x){
    long long tmp = n, ans = 0;
    while(tmp){
        ans += tmp % x;
        tmp /= x;
    }
    return ans;
}
 
signed main(){
    cin >> n >> s;
    for(long long i = 2; i * i <= n; i++){
        if(sum(i) == s){
            cout << i;
            return 0;
        }
    }
    for(long long i = sqrt(n) - 1; i >= 1; i--){
        if(s < i) continue;
        long long tmp = n - (s - i);
        if((tmp % i) != 0) continue;
        if((tmp / i) <= (s - i)) continue;
        if((tmp / i) == 1) continue;
        cout << tmp / i;
        return 0;
    }
    if(s == 1){
        if(n == 1) cout << 2;
        else cout << n;
        return 0;
    }
    if(s == n){
        cout << n + 1;
        return 0;
    }
    cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,ans=1;
  cin>>n;
  vector<int>d(n);
  rep(i,n){
    cin>>d.at(i);  
  }
  sort(d.begin(),d.end());
  rep(i,n-1){
    if (d.at(i+1)>d.at(i)) {
      ans+=1;
    }  
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] h = new long[n];
    long max = h[0];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    for (int i = 0; i < n -1; i++) {
      max = Math.max(max, h[i]);
      long x = max - h[i + 1];
      if (x > 1) {
        System.out.println("No");
        System.exit(0);  
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 50224
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void) {
    double N,D;
    cin>>N>>D;
    int ans=0;

    vector<double>X(N);
    vector<double>Y(N);

    for(int i=0;i<N;i++){
        cin>>X[i];
        cin>>Y[i];

    }

    for(int i=0;i<N;i++){
        double a=pow(X[i],2.0);
        double b=pow(Y[i],2.0);
        double c=a+b;
        double d=pow(c,0.5);

        if(D>=d){
            ans++;
        }

    }


    cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;

    if(s[1]=='B') s[1]='R';
    else s[1]='B';

    cout << s;

    return 0;
} 

Measured memory_bytes: 3604
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };





signed main() {
	string s;
	int cnt = 0;

	cin >> s;

	for (int i = 0, j = s.length() - 1; i < s.length() / 2; i++, j--) {
		if (s[i] != s[j]) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(int argc, const char * argv[]) {
    // insert code here...
    
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            cout << i << "x" << j << "=" << i*j << endl;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(50), C(50);
  for(int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(V.at(i) > C.at(i)) {
      ans += (V.at(i) - C.at(i));
    }
  }
  cout << ans << endl;
}

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

const int N = 1e6L + 11;
int c[N];
int cnt[N];
int ans[N];
vector <int> v[N];

int main() {
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		scanf("%d", c + i);
		cnt[c[i]] ++;
		v[c[i]].push_back(i);
	}
	multiset <int> st;
	st.insert(0);
	for(int i = 1; i <= m; i ++)
		st.insert(cnt[i]);
	for(int i = 1; i <= m; i ++) {
		ans[i] = n - cnt[i];
		for(int t = 0; t < 2; t ++) {
			//cout << "------\n";
			//cout << i << ' ' << t << '\n';
			vector <int> his;
			for(int x : v[i]) {
				int op = ((x & 1) == t ? x - 1 : x + 1);
				if(op > x && c[op] == c[x])
					continue;
				his.push_back(c[x]);
				st.erase(st.find(cnt[c[x]]));
				cnt[c[x]] --;
				st.insert(cnt[c[x]]);
				if(op >= 1 && op <= n) {
					his.push_back(c[op]);
					st.erase(st.find(cnt[c[op]]));
					cnt[c[op]] --;
					st.insert(cnt[c[op]]);
				}
			}
			/*
			for(int x : st)
				cout << x << '\n';
				*/
			int tmp = *st.rbegin();
			for(int x : his) {
				st.erase(st.find(cnt[x]));
				cnt[x] ++;
				st.insert(cnt[x]);
			}
			ans[i] = min(ans[i], n - cnt[i] - tmp);
		}
	}
	for(int i = 1; i <= m; i ++)
		printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 116420
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double length = 2 * r * pi;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28420
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

ll N, C, s[200000], t[200000], c[200000];
P<ll, ll> tp[200000];
ll us[100], usc[100];

ll dp[200000];

int main()
{
    //
    cin >> N >> C;
    rep(i, 0, N)
    {
        cin >> s[i] >> t[i] >> c[i];
        tp[i] = mp(s[i], i);
    }

    /*
    ll ans = 0;
    cbuf(us, -1);
    cbuf(usc, -1);
    */
    sort(tp, tp + N);
    /*
    rep(i, 0, N)
    {
        ll S = s[tp[i].second], T = t[tp[i].second], ch = c[tp[i].second];
        ll usi = 0;
        rep(j, 0, C)
        {
            if (us[j] < S || (us[j] == S && usc[j] == ch)) {
                usi = j;
                break;
            }
            if (j == C - 1) throw std::runtime_error("");
        }
        us[usi] = T;
        usc[usi] = ch;
        ans = max(ans, usi);
    }

    cout << ans + 1 << endl;
    */

    rep(ch, 1, C+1){
        ll tpr = -1;
        rep(i, 0, N){
            ll in = tp[i].second;
            if(c[in] != ch)  continue;
            dp[s[in] - 1]++;
            dp[t[in]]--;
            if(tpr == s[in]){
                dp[s[in] - 1]--;
                dp[s[in]]++;
            }
            tpr = t[in];
        }
    }




    ll ans = 0, s = 0;
    rep(i, 0, 200000){
        s += dp[i];
        ans = max(ans, s);
    }
    cout << ans << endl;


}


Measured memory_bytes: 8064
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int H, W;
  cin >> H >> W;
  ll c[10][10];
  for (auto i = 0; i < 10; ++i) {
    for (auto j = 0; j < 10; ++j) {
      cin >> c[i][j];
    }
  }
  vector<int> A;
  for (auto i = 0; i < H; ++i) {
    for (auto j = 0; j < W; ++j) {
      int x;
      cin >> x;
      if (x != -1) A.push_back(x);
    }
  }
  for (auto k = 0; k < 10; ++k) {
    for (auto i = 0; i < 10; ++i) {
      for (auto j = 0; j < 10; ++j) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  ll ans = 0;
  for (auto x : A) {
    ans = ans + c[x][1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] g = new int[n][][];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            g[i] = new int[a][2];
            for (int j = 0; j < a; j++) {
                g[i][j][0] = sc.nextInt() -1;
                g[i][j][1] = sc.nextInt();
            }
        }
        int ans = 0;
        for (int i = 0; i < 1<<n; i++) {
            int[] a = new int[n];
            boolean able = true;
            for (int j = 0; j < n; j++) {
                if((i >> j & 1) == 1){
                    a[j] = 1;
                }
            }
            for (int j = 0; j < n; j++) {
                if(a[j]==0)continue;
                for(int[] b : g[j]){
                    if(a[b[0]] != b[1]){
                        able = false;
                        break;
                    }
                }
                if(!able) break;
            }
            if(able){
                int tmp = 0;
                for (int j = 0; j < n; j++) {
                    if(a[j] == 1) tmp++;
                }
                if(ans < tmp) ans = tmp;
            }
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 25684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const int inf=1e9;
int main(){
	long A,B,N; cin>>A>>B>>N;
	if(B - 1 <= N){
		cout<<A * (B - 1) / B<<endl;
	}else{
		cout<<A * N / B<<endl;
	}
}

Measured memory_bytes: 3624
n,m = (int(i) for i in input().split())
s = str(input())
t = str(input())
gcd = 0
r = n%m
n_gcd = n
m_gcd = m
while(r != 0):
    n_gcd = m_gcd
    m_gcd = r
    r = n_gcd%m_gcd
gcd = m_gcd
L_min = int(n*m/gcd)
flg = 1
for i in range(gcd):
    if s[int(n/gcd)*i]!= t[int(m/gcd)*i]:
        flg = 0
        break
if flg==1:
    print(L_min)
else:
    print(-1)


Measured memory_bytes: 3444
#include<stdio.h>

#define STRING_SIZE_MAX 1200

#define COUNT_RESET 0

#define BOTH_LARGE_SMALL 32

#define RETURN 0

int main(){

        unsigned char usW_D_str[STRING_SIZE_MAX];        /* 文字列配列 */

        unsigned short usW_C_i;                          /* ループ変数 */

        

        /* 配列の初期化 */

        for(usW_C_i = COUNT_RESET;usW_C_i < STRING_SIZE_MAX;usW_C_i++){

                usW_D_str[usW_C_i] = '\0';

        }

        

        /* 文字列の入力 */

        for(usW_C_i = COUNT_RESET;usW_C_i < STRING_SIZE_MAX;usW_C_i++){

                scanf("%c", &usW_D_str[usW_C_i]);

                /* 入力終了処理 */

                if(usW_D_str[usW_C_i] == '\0'){

                        break;

                }

        }

        

        /* 大文字⇔小文字の変換 */

        for(usW_C_i = COUNT_RESET;usW_C_i < STRING_SIZE_MAX;usW_C_i++){

                /* 大文字から小文字の変換 */

                if(('A' <= usW_D_str[usW_C_i]) && (usW_D_str[usW_C_i] <= 'Z')){

                        usW_D_str[usW_C_i] += BOTH_LARGE_SMALL;

                }

                /* 小文字から大文字の変換 */

                else if(('a' <= usW_D_str[usW_C_i]) && (usW_D_str[usW_C_i] <= 'z')){

                        usW_D_str[usW_C_i] -= BOTH_LARGE_SMALL;

                }

                else;

        }

        

        /* 変換済み文字列の出力 */

        for(usW_C_i = COUNT_RESET;usW_D_str[usW_C_i] != '\0';usW_C_i++){

                printf("%c", usW_D_str[usW_C_i]);

        }

        

        return RETURN;

}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ans = true;

  for (int i=0; i<n; i++) {
    if (i%2 && s[i]=='R') ans = false;
    if (!(i%2) && s[i]=='L') ans = false;
  }

  cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#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>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#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 (){
	cin.tie(0);
   	ios::sync_with_stdio(false);

    int n,k,ans=0;
	string s;
	cin >> n;
	ll a[n],b[n];
	rep(i,n-1){
		cin >> b[i];
	}
	ans += b[0];
	ans += b[n-2];

	for(int i=1;i<n-1;i++){
		ans += min({b[i-1],b[i]});
	}	

	cout << ans << endl;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}
bool checkValidity(int a, int b, int c)
{
    // check condition
    if (a + b <= c || a + c <= b || b + c <= a)
        return false;
    else
        return true;
}
bool different(int i, int j, int k)
{
    if (i == j or i == k or j == k)
        return 0;
    return 1;
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    ll ans = 0;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++)
            {
                if ((checkValidity(a[i], a[j], a[k]) == 1) && (different(a[i], a[j], a[k]) == 1))
                    ans++;
            }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll prev;
    cin >> prev;
    vector<int> d;
    for (int i = 1; i < n; ++i) {
        ll x;
        cin >> x;
        if (x > prev) d.emplace_back(1);
        else if (x < prev) d.emplace_back(-1);
        prev = x;
    }

    int cnt = 0, m = (int) d.size();
    for (int i = 1; i < m; ++i) {
        if (d[i - 1] * d[i] < 0) {
            ++cnt;
            ++i;
        }
    }

    cout << cnt + 1 << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, arr[200005], occ[200005];
ll t, a;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		cin >> arr[i];
		occ[arr[i]]++;
	}
	FOR(i, 1, n) t += (ll) (occ[i] * (occ[i]-1))/2;
	FOR(i, 1, n) cout << t - occ[arr[i]] + 1 << "\n";
}


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

int main() {
	int N;
	cin >> N;
	ll ans = 0;
	vector<int> P(N), num(N + 1);
	for (int i = 0;i < N;i++) {
		cin >> P[i];
		num[P[i]] = i;
	}
	set<int> bigger;
	bigger.insert(num[N]);
	for (ll i = N - 1;i > 0;i--) {
		auto itr = bigger.upper_bound(num[i]), itl = itr;
		ll left, right, mid = num[i];
		if (itl == bigger.begin()) {
			//右側に広がるしかない
			left = num[i] + 1;
			itr++;
			if (itr == bigger.end()) {
				itr--;
				right = N - *itr;
			}
			else {
				right = *itr;
				itr--;
				right -= *itr;
				itr++;
			}
			ans += (left * right)*i;
		}
		else {
			itl--;
			//左に広がるパターン
			if (itl == bigger.begin()) {
				left = *itl + 1;
			}
			else {
				left = *itl;
				itl--;
				left -= *itl;
				itl++;
			}
			if (itr == bigger.end()) {
				right = N - num[i];
			}
			else {
				right = *itr - num[i];
			}
			ans += (right * left)*i;

			//右に広がるパターン
			left = num[i];
			left -= *itl;
			if (itr == bigger.end()) {
				//右に広がれない
				right = 0;
			}
			else {
				itr++;
				if (itr == bigger.end()) {
					itr--;
					right = N - *itr;
				}
				else {
					right = *itr;
					itr--;
					right -= *itr;
					itr++;
				}
			}
			//cout << left << " " << right << " " << i << " " << ans << endl;
			ans += (right * left)*i;
		}
		//cout << ans << endl;
		bigger.insert(num[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    long long int n;
    cin >> n;
    long long int a, b;
    vector<long long int> v, w;
    long long int i;
    long long int count = 0;
    long long int til = 0;
    
    for(i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }
    
    for(i = 0; i < n; i++){
        cin >> b;
        if(v[i] < b){
            count++;
            til += b-v[i];
        }else{
            w.push_back(v[i]-b);
        }
    }
    
    if(count == 0){
        cout << 0 << endl;
        return 0;
    }
    
    sort(w.begin(), w.end(), greater<long long int>());
    
    long long int c = 0;
    
    for(i = 0; i < w.size(); i++){
        c += w[i];
        count++;
        if(c >= til){
            cout << count << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 2548
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	printf("%d\n",a[n-1]-a[0]);
	return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  char u;
  cin >>u;
  cout <<(char)(u+1);
}

Measured memory_bytes: 3600
from sys import stdin
input = stdin.readline

a, b, k = map(int, input().split())
cou = 0
if a > b:
    a, b = b, a

for i in range(a, 0, -1):
    if a % i == 0 and b % i == 0:
        cou += 1
    if cou == k:
        ans = i
        break

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#define N 1000000 
using namespace std;
int head,tail;
struct po{
  int x;
  string name;
};
po Q[N];

void pop(){
  head=(head+1)%N;  
}

void push(po x){
  Q[tail]=x;
  tail=(tail+1)%N;
}

po front(){return Q[head];}

int main(){
  int n,q;
  cin>>n>>q;
  string str;
  for(int i=0,a;i<n;i++){
    cin>>str>>a;
    po t;
    t.x=a,t.name=str;
    push(t);
  }

  int time=0;
  while(head!=tail){
    po t=front();pop();
    time+=min(q,t.x);
    if(t.x<=q)cout << t.name <<" "<<time<<endl; 
    else t.x-=q,push(t);
  }
  return 0;
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
deque<int> a;

void input(){
  cin >> n;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    a.push_back(x);
  }
  a.push_front(0);
  a.push_back(0);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  int s = 0;
  for(int i=0;i<a.size()-1;i++){
    s += abs(a[i+1]-a[i]);
  }
  for(int i=1;i<a.size()-1;i++){
    cout << s + (abs(a[i+1]-a[i-1]) - abs(a[i+1]-a[i]) - abs(a[i]-a[i-1])) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
inline int read()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, k, tot, last[100005];
struct point
{
	int num, cnt;
}a[100005];
struct edge
{
	int u, v, last;
}e[200005];
inline void link (int u, int v)
{
	tot++;
	e[tot].u = u;
	e[tot].v = v;
	e[tot].last = last[u];
	last[u] = tot;
}
inline void get_in (int x, int fa, int z, int sum)
{
	a[x].num = a[z].num;
	a[x].cnt = sum;
	for (int i = last[x]; i; i = e[i].last)
	{
		int v = e[i].v;
		if (v != fa)
		{
			get_in (v, x, z, sum + 1);
		}
	}
}
inline bool dfs (int x, int fa)
{
	int nowx = a[x].num, nowcnt = a[x].cnt;
	for (int i = last[x]; i; i = e[i].last)
	{
		int v = e[i].v;
		if (v != fa)
		{
			bool q = dfs (v, x);
			if (!q)
			return false;
			if (a[v].num == -1)
			continue;
			if (nowx == -1 && a[v].num != -1)
			{
				nowx = a[v].num;
				nowcnt = a[v].cnt + 1;
				continue;
			}
			if (((abs(nowx - a[v].num) % 2) ^ (abs(nowcnt - (a[v].cnt + 1)) % 2)) == 1)
			return false;
			int maxnow, minnow, maxv, minv;
			maxnow = nowx + nowcnt;
			minnow = nowx - nowcnt;
			maxv = a[v].num + (a[v].cnt + 1);
			minv = a[v].num - (a[v].cnt + 1);
			if (minv > maxnow || minnow > maxv)
			return false;
			minnow = max (minnow, minv);
			maxnow = min (maxnow, maxv);
			nowx = (minnow + maxnow) >> 1;
			nowcnt = nowx - minnow;
		}
	}
	a[x].num = nowx;
	a[x].cnt = nowcnt;
	return true;
}
inline void check (int x, int fa)
{
	for (int i = last[x]; i; i = e[i].last)
	{
		int v = e[i].v;
		if (v != fa)
		{
			if (a[v].num == -1)
			get_in (v, x, x, a[x].cnt + 1);
			else
			{
				int maxx, minx, maxv, minv;
				maxx = a[x].num + a[x].cnt + 1;
				minx = a[x].num - a[x].cnt - 1;
				maxv = a[v].num + a[v].cnt;
				minv = a[v].num - a[v].cnt;
				minv = max (minx, minv);
				maxv = min (maxx, maxv);
				a[v].num = (minv + maxv) >> 1;
				a[v].cnt = a[v].num - minv;
				check (v, x);
			}
		}
	}
}
inline void print()
{
	check (1, 0);
	printf ("Yes\n");
	for (int i = 1; i <= n; i++)
	printf ("%d\n", a[i].num - a[i].cnt);
}
int main()
{
	n = read();
	for (int i = 1; i < n; i++)
	{
		int u, v;
		u = read();
		v = read();
		link (u, v);
		link (v, u);
	}
	for (int i = 1; i <= n; i++)
	a[i].num = -1;
	k = read();
	for (int i = 1; i <= k; i++)
	{
		int x, y;
		x = read();
		y = read();
		a[x].num = y;
	}
	if (dfs (1, 0))
	print();
	else
	printf ("No\n");
	return 0;
}

Measured memory_bytes: 7808
from math import ceil

N,A,B = map(int, input().split())
H = []
for i in range(N):
    H.append(int(input()))
    
H.sort(reverse=True)

# T回の攻撃で全員倒せるかを判定する関数
def enough(T:int) -> bool:
    normal = B*T   # 通常攻撃でのダメージ
    addit = A-B    # 追加攻撃でのダメージ
    
    cnt = 0        # 追加攻撃の必要回数
    for h in H:
        need_add = ceil((h-normal) / addit)
        if need_add > 0:
            cnt += need_add
        
    return cnt <= T

# enough(T) == True となる最小のTを探す
# lowの更新で終わればhighが答え、highの更新で終わってもhighが答え
def search() -> int:
    low = 0             # 絶対False
    high = 10**9 + 1    # 絶対True
    
    # midがhighでもlowでもない数になるようにする
    while high - low > 1:
        mid = (high + low) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
            
    return high

print(search())

Measured memory_bytes: 7508
import java.lang.*;
import java.util.*;


public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int k = scan.nextInt();

    int max = a;
    if (b > max) {
      max = b;
    }
    if (c > max) {
      max = c;
    }

    long sum = max * (long)Math.pow(2, k) + a + b + c - max;
    System.out.println(sum);
  }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
    queue<P> que;
    ll dist[h+1][w+1];
    ll inf=1e15;
    rep(i,h+1)rep(j,w+1) dist[i][j]=inf;
    FOR(i,1,h+1)FOR(j,1,w+1){
      cin>>a[i][j];
      if(a[i][j]=='#'){
        que.push(P(i,j));
        dist[i][j]=0;
      }
    }
    while(!que.empty()){
      P v=que.front();
      que.pop();
      rep(i,4){
        int nx=v.first+dx[i];
        int ny=v.second+dy[i];
        if(1<=nx && nx<=h && 1<=ny && ny<=w){
          if(dist[nx][ny]==inf){
            dist[nx][ny]=dist[v.first][v.second]+1;
            que.push(P(nx,ny));
          }
        }
      }
    }
    ll ans=0;
    FOR(i,1,h+1)FOR(j,1,w+1) ans=max(ans,dist[i][j]);
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int n,m,x;
  cin >> n >> m >> x;
  VI  a(m+1);
 
  for(int i=1;i<=m;i++) cin >> a.at(i);
  ll sum1=0;
  ll sum2=0;
  for(int i=1;i<=m;i++){
    if(a.at(i)<x)sum1++;
    else if(a.at(i)>x)sum2++;
  }
  ll ans=min(sum1,sum2);
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8


def get_ans():
    (l, r) = [int(i) for i in input().rstrip().split(" ")]
    if r - l <= 3000:
        ans = 2019
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, (i * j) % 2019)
                if ans == 0:
                    return 0
        return ans
    return 0


print(get_ans())


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  REP(i, N)
  cin >> a[i];
  vector<int> b;
  REP(i, N)
  {
    REP(j, a[i])
    b.push_back(i + 1);
  }
  int ans[H][W];
  int y = 0, x = 0;
  int pos = 0;
  bool right = true;
  while (pos < H * W)
  {
    ans[y][x] = b[pos];
    pos++;
    if (right)
    {
      if (x == W - 1)
      {
        right = false;
        y++;
      }
      else
        x++;
    }
    else
    {
      if (x == 0)
      {
        right = true;
        y++;
      }
      else
        x--;
    }
  }
  REP(i, H)
  {
    REP(j, W)
    {
      if (j != 0)
        cout << " ";
      cout << ans[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	int a, b;
	cin >> a >> b;
	int cnt = a + b;
	if (cnt < a - b) {
		cnt = a - b;
	}
	if (cnt < a*b) {
		cnt = a*b;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vvi a(h, vi(w));
    vector<P> mp(h*w+1);
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            mp[a[i][j]] = P(i, j);
        }
    }

    int q;
    cin >> q;
    vi r(q), l(q);
    rep(i, q) {
        cin >> l[i] >> r[i];
    }

    vi sum(h*w+1);
    rep(i, h*w-d) {
        ++i;
        sum[i+d] = sum[i] + abs(mp[i+d].first - mp[i].first) + abs(mp[i+d].second - mp[i].second);
        --i;
    }

    rep(i, q) {
        cout << sum[r[i]] - sum[l[i]] << '\n';
    }
}

Measured memory_bytes: 3328
n, m, q = map(int, input().split())
X = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    a, b = a-1, b-1
    X.append((a, b, c, d))

import itertools
ans = -1
for C in itertools.combinations_with_replacement(range(m), n):
    temp = 0
    for i in range(q):
        a, b, c, d = X[i]
        if C[b]-C[a] == c:
            temp += d
    ans = max(ans, temp)
print(ans)


Measured memory_bytes: 68116
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	int x = stdIn.nextInt();
	int y = stdIn.nextInt();
	int[] a={0,2,0,1,0,1,0,0,1,0,1,0};
	if(a[x-1]==a[y-1]){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define FOREQ(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef vector<ll> Array;
typedef vector<Array> Matrix;
const ll MOD = 1e+9 + 9;
ll w, h, n;
ll m;
ll field[100][100];
ll Y[100];
ll ys[100];
ll xs[100];
Matrix p2[100];

void PrintMatrix(const Matrix &mat) {
  REP(y, mat.size()) {
    REP(x, mat[y].size()) {
      printf("%lld ", mat[y][x]);
    }
    puts("");
  }
  puts("");
}

Matrix Mul(const Matrix &lhs, const Matrix &rhs) {
  const ll h = lhs.size();
  const ll in = lhs[0].size();
  const ll w = rhs[0].size();
  assert(lhs[0].size() == rhs.size());
  Matrix ret(h, Array(w, 0));
  REP(y, h) REP(i, in) REP(x, w) {
    ret[y][x] = (ret[y][x] + lhs[y][i] * rhs[i][x]) % MOD;
  }
  return ret;
}

void Make(ll n) {
  p2[0] = Matrix(n, Array(n, 0));
  p2[1] = Matrix(n, Array(n, 0));
  REP(x, n) {
    p2[0][x][x] = 1;
    FOREQ(dx, -1, 1) {
      if (0 <= x + dx && x + dx < n) { p2[1][x][x + dx] = 1; }
    }
  }
  FOREQ(i, 1, 64) { p2[i + 1] = Mul(p2[i], p2[i]); }
}

void PowMod(ll power, Matrix &vect) {
  ll index = 0;
  while (power > 0) {
    if (power & 1) { vect = Mul(p2[index + 1], vect); }
    index++;
    power >>= 1;
  }
}

int main() {
  int test_case = 0;
  while (scanf("%lld %lld %lld", &w, &h, &n), w|h|n) {
    test_case++;
    Make(w);
    MEMSET(field, 0);
    {
      set<ll> open;
      open.insert(0);
      open.insert(h - 1);
      REP(i, n) {
        scanf("%lld %lld", &xs[i], &ys[i]);
        xs[i]--; ys[i]--;
        if (xs[i] < 0 || xs[i] >= w || ys[i] < 0 || ys[i] >= h) {
          i--; n--;
          continue;
        }
        open.insert(ys[i] - 1);
        open.insert(ys[i]);
        open.insert(ys[i] + 1);
      }
      map<ll, ll> mapto;
      m = 0;
      FORIT(it, open) {
        if (*it < 0 || *it >= h) { continue; }
        Y[m] = *it;
        mapto[*it] = m++;
      }
      REP(i, n) {
        field[mapto[ys[i]]][xs[i]] = 1;
      }
    }
    Matrix prev(w, Array(1, 0));
    prev[0][0] = 1;
    REP(y, m - 1) {
      Matrix next(w, Array(1, 0));
      if (Y[y + 1] - Y[y] == 1) {
        REP(x, w) {
          FOREQ(dx, -1, 1) {
            if (x + dx < 0 || x + dx >= w) { continue; }
            if (field[y + 1][x + dx] == 1) { continue; }
            next[x + dx][0] += prev[x][0];
          }
        }
      } else {
        next = prev;
        PowMod(Y[y + 1] - Y[y], next);
      }
      prev = next;
    }
    printf("Case %d: %lld\n", test_case, prev[w - 1][0]);
  }
}

Measured memory_bytes: 4088
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i,s.size()) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int n,i,k=4,f;string s,o;
int main(){
    cin>>n>>o;
    s=o;
    for(;k--&&!f;){
        s[0]=k>>1?'S':'W';
        s[1]=k&1?'S':'W';
        for(i=2;i<n;i++)s[i]=s[i-1]^o[i-1]&4^s[i-2]&4^4;
        for(i=n,f=1;i--&&f;)if(s[i]^o[i]&4^s[(n+i-1)%n]^s[(i+1)%n]&4^4)f=0;
        f&&cout<<s<<endl;
    }
    f||cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512