akhauriyash/Code-Regression huggingface dataset:
/**
 *    author        : Saurav Paul 
 *    created       : August 15, 2020 6:00 PM
 *    Problem Name  : A - Rainy Season
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc175/tasks/abc175_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){

    string s;
    cin >> s;
    int cnt = 0 ;
    int mx = 0 ;
    for(auto x : s){
        if(x == 'R'){
            cnt ++ ;
            mx = max(mx,cnt) ;
        }
        else{
            cnt = 0 ;
        }
    }
    cout << mx << endl ;
}

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 3636
#include <stdio.h>
void swap(int *a,int *b);
int main(void) {
	int n,i,j,hanten=0;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		for(j=0;j<n-i-1;j++){
			if(a[j]>a[j+1]){
				swap(&a[j],&a[j+1]);
				hanten++;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d",a[i]);
		if(i!=n-1)printf(" ");
	}
	puts("");
	printf("%d\n",hanten);
	return 0;
}
void swap(int *a,int *b){
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
	return;
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   ll N, H;
   cin >> N >> H;
   vector<ll> b(N);
   ll Max = -1;
   for (int i = 0; i < N; i++) {
      ll a;
      cin >> a >> b[i];
      Max = max(Max, a);
   }
   sort(b.begin(), b.end(), greater<ll>());

   ll cnt = 0;
   for (int i = 0; i < N; i++) {
      if (b[i] > Max) {
         H -= b[i];
         cnt++;
      } else {
         break;
      }
      if (H <= 0) {
         break;
      }
   }

   if (H > 0) {
      cnt += H%Max ? H/Max+1 : H/Max;
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 1024
n = int(input())
b_list = list(map(lambda x: int(x), input().split()))
a_list = [0] * n

for i in range(n):
    if i == 0:
        a_list[i] += b_list[0]
    elif i == n-1:
        a_list[i] += b_list[n-2]
    else:
        a_list[i] += min(b_list[i-1], b_list[i])
            
ans = sum(a_list)
print(ans)

Measured memory_bytes: 38460
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

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

  // ll n, w;
  // cin >> n >> w;
  // vector<ll> x(n), v(n);
  // for (int i = 0; i < n; ++i) {
  //   cin >> x[i] >> v[i];
  // }
  // vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
  // for (int i = 1; i <= n; ++i) {
  //   for (int j = 0; j <= w; ++j) {
  //     dp[i][j] = dp[i - 1][j];
  //     if (x[i - 1] <= j) {
  //       dp[i][j] = max(dp[i][j], dp[i - 1][j - x[i - 1]] + v[i - 1]);
  //     }
  //   }
  // }
  // cout << dp[n][w];

  string a, b;
  cin >> a >> b;
  vector<vector<int>> dp(a.size() + 1, vector<int>(b.size() + 1));
  for (int i = 1; i <= a.size(); ++i) {
    for (int j = 1; j <= b.size(); ++j) {
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
      dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1]});
    }
  }
  int i = a.size();
  int j = b.size();
  string ans;
  while (i && j) {
    if (a[i - 1] == b[j - 1]) {
      ans += a[i - 1];
      --i;
      --j;
    } else if (dp[i - 1][j] > dp[i][j - 1]) {
      --i;
    } else {
      --j;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int n, m;
const int MAX_NM = 1000;
ll a[MAX_NM], b[MAX_NM];

int main(){
  cin >> n >> m;
  REP(i, n) cin >> a[i];
  REP(j, m) cin >> b[j];

  sort(a, a + n);
  sort(b, b + m);

  ll ans = 1;
  for(int x = n * m; x > 0; x--) {
    int ta = upper_bound(a, a + n, x) - lower_bound(a, a + n, x);
    int tb = upper_bound(b, b + m, x) - lower_bound(b, b + m, x);
    if(ta > 1 || tb > 1) {
      cout << 0 << endl;
      return 0;
    }

    if(ta == 1 && tb == 0) {
      ans = ans * (b + m - lower_bound(b, b + m, x));
      if(ans <= 0) ans = 0;
      ans = ans % MOD;
    } else if (ta == 0 && tb == 1) {
      ans = ans * (a + n - lower_bound(a, a + n, x));
      if(ans <= 0) ans = 0;
      ans = ans % MOD;
    } else if (ta == 0 && tb == 0) {
      ans = ans * ((a + n - lower_bound(a, a + n, x)) * (b + m - lower_bound(b, b + m, x)) - (n * m - x));
      if(ans <= 0) ans = 0;
      ans = ans % MOD;
    }

    // cout << "x: " << x << ", ta: " << ta << ", tb: " << tb << ", ans: " << ans << endl;
    // cout << lower_bound(a, a + n, x) - a << ", " << lower_bound(b, b + m, x) - b <<  endl;
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "2 4 3" ].parse.expand.solve == 3 );
	assert( [ "12", "100 104 102 105 103 103 101 105 104 102 104 101" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto l = 0L;
	auto r = as.sum;
	auto ans = r - l;
	foreach( a; as )
	{
		l += a;
		r -= a;
		ans = min( ans, abs( r - l ) );
	}
	return ans;
}


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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    string s;
    cin >>n>>s;

    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            for (int k = 0; k < 10; k++){
                
                bool ok=false;
                int d=1;

                for (int p = 0; p < n; p++){

                    switch (d){
                    case 1:
                        if(s[p]=='0'+i)++d;
                        break;
                    case 2:
                        if(s[p]=='0'+j)++d;
                        break;
                    case 3:
                        if(s[p]=='0'+k)ok=true;
                        break;

                    default:
                        break;
                    }
                }

                if(ok)++ans;
            }
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define bug printf("bug\n");
    #define bug2(var) cout<<#var<<" "<<var<<endl;
    #define co(q) cout<<q<<endl;
    #define all(q) (q).begin(),(q).end()
    typedef long long int ll;
    typedef unsigned long long int ull;
    const int MOD = (int)1e9+7;
    const int MAX = 1e6;
    #define pi acos(-1)
    #define inf 1000000000000000LL
    #define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll arr[120];
    ll nCr(ll n, ll r)
    {
        ll C[r+1];
        memset(C, 0, sizeof(C));
        C[0] = 1;
        for (ll i = 1; i <= n; i++)
        {
            for (ll j = min(i, r); j > 0; j--)
                C[j] = (C[j] + C[j-1]);
        }
        return C[r];
    }
    int main()
    {
    	//cout<<nCr(5,2)<<"\\\\\\\\\\\\\\\\\\\\"<<endl;
        ll tot=0;
        long double ans=0,sum=0,cnt=0;
        map<ll,int>N,R;
        int n,a,b;
        cin>>n>>a>>b;
        for(int i=0; i<n; i++){
        	cin>>arr[i];
			N[arr[i]]++;
		}
        sort(arr,arr+n);
        ll last ;
        for(int i=n-1; i>=0; i--)
        {
            sum+=arr[i];
            R[arr[i]]++;
            cnt++;
            if(cnt>b)
                break;
            if(cnt==a)
            {
                last = arr[n-1];
                ans=sum/cnt;
            }
            if(cnt>=a)
            {
                long double cur=(sum/cnt);
                if(cnt==a)
                    {tot+=nCr(N[arr[i]],R[arr[i]]);
                    }
                else if(arr[i]==last)
                {
                 tot+=nCr(N[arr[i]],R[arr[i]]);
                }
            }
        }
        cout<<setprecision(18)<<fixed<<ans<<endl;
        cout<<tot<<endl;
        return 0;
    }

Measured memory_bytes: 3812
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


Int combination(Int n, Int r) {
    if(n == 1){return 0;}
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main() {
    Int N;
    cin >> N;
    map<string,int> mp;
    vi memo = vi(N,0);

    set<string> set;
    rep(i,N){
        string s;
        cin>>s;
        std::vector<char> data(s.begin(), s.end());
        sort(data.begin(), data.end());
        std::string sorted(data.begin(), data.end());
        mp[sorted]++;
        set.insert(sorted);
    }

    Int ans =0;
    for(auto itr = set.begin(); itr != set.end(); ++itr) {
        if(memo[mp[*itr]] != 0){
            ans+= memo[mp[*itr]];
        }else{
            Int com = combination(mp[*itr],2);
            ans+=com;
        }

    }



    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16640
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    
    ll place[N + 1];
    // place[i]...値iのaにおけるindex
    
    for (int i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        place[a] = i;
        // 保持するのはindexなので、ここが普通と逆なことに注意
    }

    ll ans = 0;
    set<ll> used = {0, N + 1};
    // すでに見た要素のindexを保持する
    
    for (int i = 1; i <= N; ++i) {
        ll r, l;
        
        auto itr = used.lower_bound(place[i]);
        r = *itr;
        // lower_boundで右端を調べる(upper_boundでもいい)
        l = *(--itr);
        // その1個手前が左端
        
        ans += i * (place[i] - l) * (r - place[i]);
        used.insert(place[i]);
    }

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


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

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

using ll = long long;

int main(){
    std::string s, t;
    std::cin >> s >> t;

    std::vector<std::vector<ll>> dp(s.size()+1,std::vector<ll>(t.size()+1, 0));
    //sのi文字目,tのj文字目までで最長の部分列
    std::string ans="";
    //dp[i][j]=[i-1][j-1]+1 or [i-1][j] or [i][j-1]
    for(int i=0; i<s.size(); ++i){
        for(int j=0; j<t.size(); ++j){
            if(s[i]==t[j]){
                chmax(dp.at(i+1).at(j+1), dp.at(i).at(j)+1);
            }
            chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
            chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
        }
    }

    int i=(int)s.size(), j=(int)t.size();
    while(i>0 && j>0){
        if(dp.at(i).at(j)==dp.at(i-1).at(j)){
            --i;
        }else if(dp.at(i).at(j)==dp.at(i).at(j-1)){
            --j;
        }else{
            ans = s[i-1] + ans;
            --i; --j;
        }
    }

    std::cout << ans;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int tot=1;
  int odds=1;
  for (int i=0; i<n; i++){
    int a;
    cin >> a;
    tot *=3;
    if(a%2==1) odds*=1;
    else odds *=2;
  }
  cout << tot-odds << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> g(n, vector<int>(n, 0));
    for(int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;r--;
        g[l][r]++;
    }
    vector<int> x(q);
    vector<int> y(q);
    for(int i = 0; i < q; i++)
    {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    vector<vector<int>> d(n+1, vector<int>(n+1, 0));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            d[i+1][j+1] = d[i+1][j] + d[i][j+1] - d[i][j] + g[i][j];
        }
    }
    for(int i = 0; i < q; i++)
    {
        int l = x[i];
        int r = y[i]+1;
        cout << d[r][r] - d[r][l] - d[l][r] + d[l][l] << endl;
    }
}


Measured memory_bytes: 3712
n = int(input())
a = [None]
for i in range(n):
    adj = list(map(int,input().split()))
    a.append(adj[2:])
    
s = [None]
for i in range(1, n + 1):
    s.append([False, i])
    
time = 0

def dfs(u):
    global time
    s[u][0] = True
    time += 1
    s[u].append(time)
    
    for v in a[u]:
        if s[v][0] == False:
            dfs(v)
            
    time += 1
    s[u].append(time)
    
for i in range(1,n+1):
    if s[i][0] == False:
        dfs(i)
        
for x in s[1:]:
    print(*x[1:])


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


int main() {
	string S, T;
	cin >> S >> T;
	vector<int> start(26, -1);
	vector<int> goal(26, -1);
	for (int i = 0; i < S.size(); i++)
	{
		int a = S[i] - 'a';
		int b = T[i] - 'a';

		if (start[a] != -1 || goal[b] != -1) {
			if (start[a] != b || goal[b] != a) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			start[a] = b;
			goal[b] = a;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 776
n = int(input())
l = list(map(int, input().split()))
s = sorted(l)
cost = 0
for i in range(n):
    a = l.index(s[i])
    j = 0
    while a > i:
        j += 1
        b = l.index(s[a])
        cost += l[b]
        l[a], l[b] = l[b], l[a]
        a = b
    cost += min(s[i] * j, s[i] * 2 + s[0] * (j + 2))
print(cost)


Measured memory_bytes: 5620
//222/03/2020
#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 debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};

//template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;
//template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
//template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
//template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
//template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
//template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
//template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

ll a[200005];
ll cnt[200005];
ll used[200005];

int main(){
    _fastio
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }

    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(used[a[i]]==0){
            ll x=cnt[a[i]];
            x=(x*(x-1))/2;
            ans+=x;
            used[a[i]]=1;
        }
    }

    for(ll i=1;i<=n;i++){
        ll x=cnt[a[i]];
        ll tem=ans-(x*(x-1))/2;
        x--;
        tem+=((x*(x-1))/2);
        cout<<tem<<en;
    }



    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int H,W,h,w;
cin >> H >> W >> h >> w;
cout << (H-h)*(W-w) << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int maxa,minb;
    int a,b;
    int n,m,x,y;

    cin >> n >> m >> maxa >> minb;
    FOR(i,0,n){
        cin >> a;
        if(a > maxa)maxa = a;
    }
    FOR(i,0,m){
        cin >> b;
        if(b < minb)minb = b;
    }

    if(maxa < minb)cout << "No War";
    else cout << "War";

    return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))

    
out = ['a']*n
err_flg = False
err_flg2 = False 

for i in range(m):
    s = list(map(int, input().split()))
    # print(s)

    if s[0]==1 and s[1]==0 and n==1:
        err_flg2 = True
    elif m==0 and n==1:
        err_flg2 = True
    elif s[0]==1 and s[1]==0 and n > 1:
        # print('kore')
        err_flg = True

    if out[s[0]-1]=='a':
        out[s[0]-1] = s[1]
    elif out[s[0]-1]==s[1]:
        out[s[0]-1] = s[1]
    # elif out[s[0]-1]!=s[1]:
    elif out[s[0]-1]!=s[1]:
        err_flg = True


if out[0]=='a' and n>1:
    out[0]=1
    

out_s = "".join(map(str,out))

if err_flg2:
    print('0')
    # print('err2')
elif err_flg:
    print('-1')
    # print('err')
else:
    print(out_s.replace('a','0'))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    vector<int> v1,v2,v3;
    rep(i,n){
        int temp;
        cin>>temp;
        if(temp<=a){
            v1.push_back(temp);
        }else if( b<temp){
            v3.push_back(temp);
        }else{
            v2.push_back(temp);
        }
    }
    cout<<min(v1.size(),min(v2.size(),v3.size()))<<endl;
    return 0;

}


Measured memory_bytes: 256
W,H,x,y,r=map(int,input().split())
if H<y+r:
    print("No")#上
elif W<x+r:
    print("No")#右
elif y-r<0:
    print("No")#下
elif x-r<0:
    print("No")#左
else:
    print("Yes")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  vector<int> abc(3);
    abc[0]=a;
    abc[1]=b;
    abc[2]=c;
 
  sort(abc.begin(), abc.end());
  
  int num=0;
  int d=(abc[1]-abc[0])/2;
  
  if((abc[1]-abc[0])%2==1){
    num = num + 2;
  }
  
  num = num + d;
  
  int e=abc[2]-abc[1];
  
  num = num + e;
  
  cout << num << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//ifstream f(".in");
//ofstream g(".out");

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
//  freopen(".in", "r", stdin);
#endif

  int n, w;
  cin >> n >> w;
  const int INF = 1e9 + 5;
  vector<int> dp((int)1e5 + 5, INF);
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int weight, value;
    cin >> weight >> value;
    for (int old_v = (int)1e5; old_v >= 0; --old_v) {
      if (old_v + value <= (int) 1e5) {
        uin(dp[old_v + value], dp[old_v] + weight);
      }
    }
  }

  for (int val = (int)1e5; val >= 0; --val) {
    if (dp[val] != 0 && dp[val] <= w) {
      cout << val << '\n';
      return 0;
    }
  }
  assert(false);

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<pair<ll, ll>, bool> DP;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007, inv2=(mod+1)/2;
const int MAXN=300010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll A[MAXN];

ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}

DP Get(DP p, int ted){
	p.first.first=p.first.first*powmod(2, ted)%mod;
	return p;
}

DP Merge(DP p, DP q){
	if (!p.second) return q;
	if (!q.second) return p;
	ll dp=(p.first.first*q.first.first)%mod*inv2%mod;
	return {{dp, ((p.first.first+p.first.second)*(q.first.first+q.first.second)-dp)%mod}, 1};
}

DP Solve(int tl, int tr, int h){
//	cerr<<"Solve "<<tl<<" "<<tr<<" "<<h<<"\n";
	if (tl>tr) return {{0, 0}, 0};
	if (tl==tr) return Get({{2, 0}, 1}, A[tl]-1-h);
	ll mn=inf, pos;
	for (int i=tl; i<=tr; i++) if (A[i]<mn) mn=A[i], pos=i;
	int last=tl;
	DP res={{0, 0}, 0};
	for (int i=tl; i<=tr; i++) if (A[i]==mn){
		res=Merge(res, Solve(last, i-1, mn-1));
		res=Merge(res, {{2, 0}, 1});
		last=i+1;
	}
	if (last<=tr) res=Merge(res, Solve(last, tr, mn-1));
	res=Get(res, mn-1-h);
	
//	cerr<<"Solve "<<tl<<" "<<tr<<" "<<h<<":  "<<res.first.first<<" "<<res.first.second<<"\n";
	
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i];
	DP res=Solve(1, n, 0);
	ans=(res.first.first+res.first.second+2ll*mod)%mod;
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3684
import Data.Char
import Data.List
import Data.Bits
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- head.parseLine <$> BS.getLine
  as <- parseLine <$> BS.getLine
  print $ solve n as
  where
    parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)

solve :: Int -> [Int] -> Integer
solve n as = (`mod` (10^9+7)) . (calcEachBitResults n) . aggregateBits $ as

aggregateBits :: [Int] -> [Int]
aggregateBits as = map (countBits as) [0..(bitLength as-1)] 

bitLength :: [Int] -> Int
bitLength as = finiteBitSize (maximum as) - countLeadingZeros (maximum as)

countBits :: [Int] -> Int -> Int
countBits as d = length . filter (flip testBit d) $ as

calcEachBitResults :: Int -> [Int] -> Integer
calcEachBitResults n = sum . zipWith (\d x -> 2^d*x) [0..] . map ((\x -> x * (n'-x)).fromIntegral)
  where
    n' = fromIntegral n

Measured memory_bytes: 21884
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int a[2][110];
	cin >> N;
	REP(j, 2){
		REP(i, N){
			cin >> a[j][i];
		}
	}
	ll res = 0;
	REP(i, N){
		ll sum = 0;
		REP(j, i+1)
			sum += a[0][j];
		FOR(j, i, N)
			sum += a[1][j];
		res = max(res, sum);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,i,j,x,y,z;
  scanf("%d", &n);
  int a[n+1];
  int b[51];
  int c[51];
  for(x=1;x<=n;x++){
    scanf("%d", &a[x]);
  }
  for(y=1;y<=n;y++){
    scanf("%d", &b[y]);
  }
  for(z=1;z<=n-1;z++){
    scanf("%d", &c[z]);
  }
  int sum=0;
  
  for(i=1;i<=n;i++){
    sum += b[i];
  }
  
  for(j=1;j<=n-1;j++){
    if(a[j]+1==a[j+1]){
      sum += c[a[j]];
  }
 }
  printf("%d", sum);
  return 0;
}


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

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

    int n = s.length();

    if(n >= 10){
        cout << "NO" << endl;
    }else{
        int poj = -1;
        int cou = 0;
        for(int i = 0; i < n - 3; i++){
            if(s.substr(i, 3) == "KIH"){
                poj = i + 3;
                break;
            }else{
                if(s[i] == 'A'){
                    cou++;
                }else{
                    break;
                }
            }

            if(cou == 2){
                break;
            }
        }

        if(poj != -1){
            cou = 0;
            for(int i = poj; i < n; i++){
                if(s[i] == 'B'){
                    poj = i;
                    break;
                }else if(s[i] == 'A'){
                    cou++;
                }else{
                    poj = -1;
                    break;
                }

                if(cou == 2){
                    poj = -1;
                    break;
                }
            }

            if(poj != -1){
                cou = 0;
                int t = poj;
                for(int i = poj + 1; i < n; i++){
                    if(s[i] == 'R'){
                        poj = i;
                        break;
                    }else if(s[i] == 'A'){
                        cou++;
                    }else{
                        poj = -1;
                        break;
                    }

                    if(cou == 2){
                        poj = -1;
                        break;
                    }
                }

                if(t == poj){
                    poj = -1;
                }

                if(poj != -1){
                    if(poj == n - 2 || poj == n - 1){
                        if(poj == n - 2){
                            if(s[poj + 1] != 'A'){
                                poj = -1;
                            }
                        }
                    }else{
                        poj = -1;
                    }
                }
            }
        }
        if(poj == -1){
            cout << "NO" << endl;
        }else{
            cout << "YES" << endl;
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    int si, sj, gi, gj;
    cin >> si >> sj >> gi >> gj;
    si--, sj--, gi--, gj--;

    vector<string> c(H);
    for (auto &i : c) cin >> i;

    auto bfs = [&]() {
        using info = tuple<P, P, int>;
        priority_queue<info, vector<info>, greater<info>> q;

        vector<vector<vector<P>>> dist(H, vector<vector<P>>(W, vector<P>(4, P(INF, 0))));
        rep(i, 4) {
            dist[si][sj][i] = P(1, 0);
            q.emplace(P(1, 0), P(si, sj), i);
        }

        while (q.size()) {
            auto item = q.top(); q.pop();
            auto d = get<0>(item);
            auto p = get<1>(item);
            int i = p.first, j = p.second;
            int v = get<2>(item);

            if (dist[i][j][v] < d) continue;

            // 現在の向きに進む
            {
                int ni = i, nj = j;
                if (v == 0) ni--;
                if (v == 1) nj--;
                if (v == 2) ni++;
                if (v == 3) nj++;

                auto np = d;
                if (np.second < K) np.second++;
                else np.first++, np.second = 1;

                if (0 <= ni && ni < H && 0 <= nj && nj < W && np < dist[ni][nj][v] && c[ni][nj] != '@') {
                    dist[ni][nj][v] = np;
                    q.emplace(np, P(ni, nj), v);
                }
            }

            // 方向を転換する
            {
                rep(nv, 4) {
                    if (v == nv) continue;
                    auto np = dist[i][j][v];
                    np.first++, np.second = 0;
                    if (np < dist[i][j][nv]) {
                        dist[i][j][nv] = np;
                        q.emplace(np, P(i, j), nv);
                    }
                }
            }
        }

        int res = INF;
        rep(i, 4) chmin(res, dist[gi][gj][i].first);
        return res;
    };

    auto ans = bfs();
    if (ans == INF) {
        puts("-1");
        return 0;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 144960
import java.util.*;

class Main{
	public static void main(String[] args){
		int n;
		final int MAX_N = 10000;
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> al = new ArrayList<Integer>();
		for(int i = 2;al.size() < MAX_N;i++){
			boolean b = true;
			for(int j = 0;j < al.size();j++){
				if(i % al.get(j) == 0){
					b = false;
					break;
				}
			}
			if(b){
				al.add(i);
			}
		}
		al.add(0,0);
		for(int i = 1;i < al.size();i++){
			al.set(i, al.get(i - 1) + al.get(i));
		}
		while(true){
			n = scan.nextInt();
			if(n == 0){
				break;
			}
			System.out.println("" + al.get(n));
		}
	}
}

Measured memory_bytes: 22848
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, H, M) = Read4Longs();

            var h = 2 * Math.PI * ((double)H / 12) + 2 * Math.PI * ((double)M / 720);
            var m = 2 * Math.PI * (double)M / 60;

            //if (Math.Abs(h - m) == 2 * Math.PI) return Math.Abs(A - B);
            //if (h == m) return Math.Abs(A - B);

            var abs = Math.Abs(m - h);
            var theta = abs < Math.PI ? abs : (2 * Math.PI - abs);

            var cosC = Math.Cos(theta);
            if (cosC == 1) return Math.Abs(A - B);
            if (cosC == -1) return A + B;

            return Math.Sqrt(A * A + B * B - 2 * A * B * cosC);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vec<int> a(n);
  rep(i, n) cin >> a[i];
  vec<int> cnt(M);
  for(int x : a) {
    if(cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for(int x : a) {
    if(cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7996
A, B = map(int, input().split())

whiteline = list("."*100)
blackline = list("#"*100)
checkline = ["." if i%2 == 0 else "#" for i in range(100)]

ans = []
b = B-1
for h in range(21):
    if h%2 == 0:
        ans.append(whiteline)
    else:
        if b >= 50:
            ans.append(checkline)
            b -= 50
        elif b > 0:
            P = list("."*100)
            for i in range(b):
                P[2*i] = "#"
            b = 0
            ans.append(P)
        else:
            ans.append(whiteline)
a = A-1
for h in range(21):
    if h%2 == 0:
        ans.append(blackline)
    else:
        if a >= 50:
            ans.append(checkline)
            a -= 50
        elif a > 0:
            P = list("#"*100)
            for i in range(a):
                P[2*i] = "."
            a = 0
            ans.append(P)
        else:
            ans.append(blackline)

print(len(ans), len(ans[0]))
for L in ans:
    print("".join(L))

Measured memory_bytes: 3064
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        H: usize,
        W: usize,
        S: [chars; H]
    }

    let mut A = vec![vec![-1; W]; H];
    A[0][0] = 1;

    let mut queue:VecDeque<(usize,usize)> = VecDeque::new();
    queue.push_back((0,0));

    while !queue.is_empty() {
        let (x,y) = queue.pop_front().unwrap();

        if S[x][y] == '#'{
            continue;
        }

        for &(dx,dy) in &[(0,1),(0,-1),(1,0),(-1,0)]{
            let nx = x as i64 + dx;
            let ny = y as i64 + dy;
            if 0<=nx && nx<H as i64  && 0<=ny && ny<W as i64{
                let nx = nx as usize;
                let ny = ny as usize;
                if S[nx][ny]=='.' && A[nx][ny] == -1{
                    A[nx][ny] = A[x][y] + 1;
                    queue.push_back((nx,ny));
                }
            }
        }
    }

    let mut cnt_white = 0;
    for h in 0..H{
        for w in 0..W{
            if S[h][w]=='.'{
                cnt_white += 1;
            }
        }
    }

    if A[H-1][W-1] == -1{
        println!("-1");
    }else{
        println!("{}", cnt_white - A[H-1][W-1]);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

 
     signed main(){
     int h,w,d;
     cin>>h>>w>>d;
     char ans[4];
     ans[0]='R';ans[1]='Y';ans[2]='G';ans[3]='B';
     for(int i=0;i<h;i++){for(int j=0;j<w;j++){
          cout<<ans[(MOD*d+i-j)/d%2*2+(MOD*d+i+j)/d%2];
     }
     cout<<endl;
     }
     

   

      }

        

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

#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll red,green,blue,k;
      cin>>red>>green>>blue;
      cin>>k;

      while(k--){
            if(green<=red) {green*=2;continue;}
            if(blue<=green){blue*=2;continue;}
      }

      if(red<green && green<blue){cout<<"Yes"<<endl;}
      else cout<<"No"<<endl;


      bye;
}


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

int main()
{
    int n, q;
    ll ans=0;
    vector<int> a(200000), count(200000, 0);

    cin >> n;
    rep(i, n)
    {
        cin >> a.at(i);
        count.at(a.at(i))++;
        ans += a.at(i);
    }
    cin >> q;
    rep(i, q)
    {
        int b, c;
        cin >> b >> c;
        ans += (c - b) * count.at(b);
        count.at(c) += count.at(b);
        count.at(b) = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> xx(n);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    cin >> xx[i];
    res += min(xx[i], abs(k - xx[i])) * 2;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 100 + 5;

int main(){
	int k,a,b,flag = 0;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			flag = 1;
			break;
		}
	}
	if(flag)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>

using namespace std;

int a[200005],b[200005];
int c[200005];

int main(void)
{
    int n; scanf("%d",&n); 
    for(int i=0;i<n;++i) scanf("%d",&a[i]), b[i] = a[i], ++c[a[i]];
    sort(b,b+n);
    int len = unique(b,b+n)-b;
    long long num = 0;
    for(int j=0;j<len;++j){
        long long x = c[b[j]];
        num += x*(x-1)/2;
    }
    for(int i=0;i<n;++i){
        long long cnt = num;
        long long x = c[a[i]];
        cnt -= x*(x-1)/2;
        --x;
        if(x>1) cnt += x*(x-1)/2;
        printf("%lld\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#ifdef LOCAL
template <class S, class T>
ostream &operator<<(ostream &str, const pair<S, T> &p) {
  return (str << "{" << p.fi << ", " << p.se << "}");
}
template <template <class...> class Container, class... T>
ostream &operator<<(ostream &str, const Container<T...> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << (x) << "] "
struct dbg {
  dbg() { cout << "  "; }
  ~dbg() { cout << endl; }
  template <class T> dbg &operator<<(T oth) {
    cout << oth;
    return *this;
  }
};
#else
#define var(x) 0
struct dbg {
  template <class T> dbg &operator<<(T oth) { return *this; }
};
#endif
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      if ((i & 1) && (x & 1))
        ++ans;
    }
    cout << ans << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


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

int main() {
  int d;
  int c[26];
  int last[26];
  scanf("%d", &d);
  for ( int i = 0; i < 26; i++ ) {
    scanf("%d", &c[i]);
    last[i] = 0;
  }
  int s[d][26];
  for ( int i = 0; i < d; i++ ) {
    for ( int j = 0; j < 26; j++ ) {
      scanf("%d", &s[i][j]);
    }
  }

  int t[d];
  for ( int i = 0; i < d; i++ ) {
    cin >> t[i];
    t[i]--;
  }

  int now = 0;
  int val = 0;
  while ( now < d ) {
    int contest = t[now];
    val += s[now][contest];
    now++;
    last[contest] = now;
    for ( int i = 0; i < 26; i++ ) {
      val -= c[i]*(now-last[i]);
    }
    //printf("%d\n", val);
  }

  int m;
  scanf("%d", &m);
  while ( m-- > 0 ) {
    int change_day, after_contest;
    scanf("%d %d", &change_day, &after_contest);
    change_day--;
    after_contest--;
    int bef_contest = t[change_day];
    t[change_day] = after_contest;
    val -= s[change_day][bef_contest];
    val += s[change_day][after_contest];
    
    int last_bef_front = -1;
    for ( int i = change_day-1; i >= 0; i-- ) {
      if ( t[i] == bef_contest ) { last_bef_front = i; break; }
    }
    int last_bef_back = d;
    for ( int i = change_day+1; i < d; i++ ) {
      if ( t[i] == bef_contest ) { last_bef_back = i; break; }
    }
    val += c[bef_contest]*((change_day-last_bef_front)*(2+(change_day-last_bef_front-1))/2);
    val += c[bef_contest]*((last_bef_back-change_day)*(2+(last_bef_back-change_day-1))/2);
    val -= c[bef_contest]*((last_bef_back-last_bef_front)*(2+(last_bef_back-last_bef_front-1))/2);

    int last_after_front = -1;
    for ( int i = change_day-1; i >= 0; i-- ) {
      if ( t[i] == after_contest ) { last_after_front = i; break; }
    }
    int last_after_back = d;
    for ( int i = change_day+1; i < d; i++ ) {
      if ( t[i] == after_contest ) { last_after_back = i; break; }
    }
    val -= c[after_contest]*((change_day-last_after_front)*(2+(change_day-last_after_front-1))/2);
    val -= c[after_contest]*((last_after_back-change_day)*(2+(last_after_back-change_day-1))/2);
    val += c[after_contest]*((last_after_back-last_after_front)*(2+(last_after_back-last_after_front-1))/2);

    printf("%d\n", val);
  }

  return 0;
}


Measured memory_bytes: 3772