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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

bool dp[81][81][81*81*4];
int mp[81][81];
const int seica = 81*81*2;

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

	ll w, h;cin >> h >> w;
	REP(i, h){
		REP(j, w){
			ll a;cin >> a;
			mp[i][j] += a;
		}
	}
	REP(i, h){
		REP(j, w){
			ll a;cin >> a;
			mp[i][j] -= a;
		}
	}

	dp[0][0][seica] = true;
	REP(i, h){
		REP(j, w){
			REP(k, 81*81*4)if(dp[i][j][k]){
				dp[i+1][j][k + mp[i][j]] |= dp[i][j][k];
				dp[i][j+1][k + mp[i][j]] |= dp[i][j][k];
				dp[i+1][j][k - mp[i][j]] |= dp[i][j][k];
				dp[i][j+1][k - mp[i][j]] |= dp[i][j][k];
			}
		}
	}
	ll ans = INF;

	REP(i, 81*81*4){
		if(!dp[h][w-1][i] && !dp[h-1][w][1])continue;
		ans = min(ans, abs(i - seica));
		ans = min(ans, abs(i - seica));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 167168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    auto A = make_v<int>(3, 3);
    auto ana = make_v<bool>(3, 3);
    rep(y, 3)
    {
        rep(x, 3)
        {
            cin >> A[x][y];
            ana[x][y] = false;
        }
    }
    int N;
    cin >> N;
    rep(i, N)
    {
        int b;
        cin >> b;
        rep(y, 3)
        {
            rep(x, 3)
            {
                if (A[x][y] == b)
                {
                    ana[x][y] = true;
                }
            }
        }
    }
    bool ans = false;
    rep(x, 3)
    {
        if (ana[x][0] and ana[x][1] and ana[x][2])
        {
            ans = true;
            cout << "Yes";
            return 0;
        }
    }
    rep(y, 3)
    {
        if (ana[0][y] and ana[1][y] and ana[2][y])
        {
            ans = true;
            cout << "Yes";
            return 0;
        }
    }
    if (ana[0][0] and ana[1][1] and ana[2][2])
    {
        ans = true;
        cout << "Yes";
        return 0;
    }
    if (ana[2][0] and ana[1][1] and ana[0][2])
    {
        ans = true;
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int k;
  int a, b;
  std::cin >> k >> a >> b;
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      std::cout << "OK" << '\n';
      return 0;
    }
  }
  std::cout << "NG" << '\n';
  return 0;
}


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

const int MAXN = 1e2+5;
const int MAXNN = 1e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

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

long long a[MAXN],sums[MAXN][MAXNN],dp[MAXN][MAXNN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n,k;cin >> n >> k;
    for(int i=1;i<=n;++i) cin >> a[i];
    dp[0][0] = 1;
    for(int i=0;i<=k;++i) sums[0][i] = 1;

    for(int i=1;i<=n;++i){
        for(int j=0;j<=k;++j){
            dp[i][j] = sums[i-1][j];
            if(j >= a[i] + 1) dp[i][j] -= sums[i-1][j-a[i]-1];
        }
        sums[i][0] = dp[i][0];
        for(int j=1;j<=k;++j) sums[i][j] = (sums[i][j-1] + dp[i][j]);
        for(int j=0;j<=k;++j) dp[i][j] = MOD(dp[i][j]),sums[i][j] = MOD(sums[i][j]);
    }
    cout << MOD(dp[n][k]);
}


Measured memory_bytes: 159232
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<char> a(n);
  vector<char> b(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
  for(int i=0; i<n; i++){
    cout << a[i];
    cout << b[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int h,w,k;
  cin>>h>>w>>k;
  int a[h][w];
  rep(i,0,h){
    string s;
    cin>>s;
    rep(j,0,w){
      if(s[j]=='.') a[i][j]=0;
      else a[i][j]=1;
    }
  }
  int ans=0;
  rep(num1,0,1<<h){
    rep(num2,0,1<<w){
      int b[h][w];
      rep(i,0,h) rep(j,0,w) b[i][j]=a[i][j];
      rep(i,0,h){
        rep(j,0,w){
          if((num1>>i)&1 ==1 || (num2>>j)&1==1){
            b[i][j]=0;
          }
        }
      }

      int cnt=0;
      rep(i,0,h) rep(j,0,w) if(b[i][j]) cnt++;
      if(cnt==k) ans++;
    }
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

const int MOD = 1000000007;

int main() {
    int k, x;
    cin >> k >> x;
    bool flag = false;
    for(int i = -1000000; i <= 1000000; i++) {
        if(x - k < i && i < x + k) {
            if(flag) {
                cout << " ";
            } else {
                flag = true;
            }
            cout << i;
        }
    }
    cout << endl;

    return 0;
}



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

signed main(void){
  string s,t; cin >> s >> t;
  if( t.substr(0,(int)t.size()-1) == s ){ 
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}
   

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  int yes = true;
  repp(i, 0, A - 1) {
    if (!isdigit(S[i])) yes = false;
  }
  if (S[A] != '-') yes = false;
  repp(i, A + 2, A + B - 1) {
    if (!isdigit(S[i])) yes = false;
  }
  if (yes)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,k,i,j;
		cin>>k>>n;
		for(i=n-k+1;i<n+k;i++){
			cout<<i<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  vector<int> b(100000);
  rep(i, 0, n) {
    cin >> a[i];
    if(a[i] != 0) b[a[i]-1]++;
    b[a[i]]++;
    if(a[i] != 100000 -1) b[a[i]+1]++;
  }
  int maxi = 0;
  rep(i, 0, 100000)
    maxi = max(b[i], maxi);
  cout << maxi << "\n";

}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  ll X;
  cin >> X;
  ll ans = 360 / gcd(X, 360);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3596
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	if (K % 2 == 0 || K % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}

	ll ans = 0;

	ll n = 7;
	while(1) {
		ans++;
		if (n % K == 0) break;

		n %= K;
		n = n * 10 + 7;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))

cnt = 0

for i in A:
    if i < 0:
        cnt += 1

A = [abs(i) for i in A]
if cnt % 2 == 0:
    print(sum(A))
else:
    print(sum(A) - 2 * min(A))

Measured memory_bytes: 14412
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll ;
const int MAXN = 5*1e5 + 10;
vector<pair<int,int>> adj[MAXN] ;
bool v[MAXN] ;
void dfs(int s) {
    
    v[s] = true ;
    for(int i= 0;i<sz(adj[s]) ;i++)
    {
        int e = adj[s][i].F ;
        if(v[e] == false) dfs(e) ;
    }
}
int main () {
    
    int N , M ;
    cin >> N >> M ;
    for(int i = 1 ; i <= M ; i++)
    {
        int u , v , w ;
        cin >> u >> v >> w;
        adj[u].pb(mk(v,w)) ;
        adj[v].pb(mk(u,w)) ;
    }
    for(int i =0 ; i < MAXN ;i++)
        v[i] = false ;
    int cnt =0 ;
    for(int i = 1 ; i <= N ;i++)
        if(v[i]==false) {
            dfs(i) ;
            cnt ++ ;
        }
    cout<<cnt<<endl ;
    
    return 0 ;
}


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

using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 1; i <= (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}



int main(){
  int n,m;
  std::cin >> n>>m;
  ll ans=0;
  rep(i,m){
    ll temp;std::cin >> temp;
    ans+=temp;
  }
  std::cout << (n-ans>=0?n-ans :-1)<< '\n';


}


Measured memory_bytes: 3640
n = int(input())
a = [[0] + list(map(int, input().split())) for _ in range(2)]
dp = [[0]*(n+1) for _ in range(2)]

for i in range(n):
    dp[0][i+1]=dp[0][i] + a[0][i+1]
    
for i in range(n):
    dp[1][i+1]=max(dp[1][i], dp[0][i+1])+a[1][1+i]

print(dp[1][n])        

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++ 
signed main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(b-a)<=d&&abs(c-b)<=d||abs(c-a)<=d){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}


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

using namespace std;
using ll = long long;

int main() {
    int N[10001] = {};
    for(int x = 1; x <= 100; x++) {
        for(int y = 1; y <= 100; y++) {
            for(int z = 1; z <= 100; z++) {
                int f = x * x + y * y + z * z + x * y + y * z + z * x;
                if(f <= 10000) N[f]++;
            }
        }
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cout << N[i] << endl;
    }
}

Measured memory_bytes: 3604
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int a, b;
  ci(a, b);
  a + b >= 24 ? co(a + b - 24) : co(a + b);
}

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

using namespace std;

struct pairs
{
    int a;
    int b;
    int c;
    int d;
};

int a[503][503];

vector<pairs> p;

void allprint()
{
    for(int i = 0; i < p.size(); i++)
    {
        cout << 
        (p[i].a + 1) << " " << 
        (p[i].b + 1) << " " << 
        (p[i].c + 1) << " " << 
        (p[i].d + 1) << endl;
    }
}

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

    for(int h = 0; h < H; h++)
    {
        for(int w = 0; w < W; w++)
        {
            cin >> a[h][w];
        }
    }

    int next = 0;

    for(int h = 0; h < H; h++)
    {
        if(h % 2== 0)
        {
            for(int w = 0; w < W; w++)
            {
                a[h][w] += next;
                if(a[h][w] % 2 != 0)
                {
                    next = 1;
                    if(w == (W -1))
                    {
                        if(h != (H - 1))
                        {
                            p.push_back({h, w, (h + 1), w});
                        }
                    }
                    else
                    {
                        p.push_back({h,  w, h , (w + 1)});
                    }

                }
                else
                {
                    next = 0;
                }
            }
        }
        else
        {
            for(int w = W - 1; w >= 0; w--)
            {
                a[h][w] += next;
                if(a[h][w] % 2 != 0)
                {
                    next = 1;
                    if(w == 0)
                    {
                        if(h != (H - 1))
                        {
                            p.push_back({h, w, (h + 1), w});
                        }
                    }
                    else
                    {
                        p.push_back({h,  w, h , (w - 1)});
                    }

                }
                else
                {
                    next = 0;
                }
            }
        }
    }

    cout << p.size() << endl;

    allprint();

    return 0;
}


Measured memory_bytes: 5104
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	a=fabs(a);
	if(c==a){
		if(b%2)
		cout<<0;
		else
		cout<<a;
	}
	else{
		if(a/c<b){
		b=b-a/c;
		if(b%2) cout<<c-a%c;
		else cout<<a%c;
	}
		else{
			cout<<a-b*c;
		}
	}
}
	

Measured memory_bytes: 3188
N = int(input())
prices = [int(n) for n in input().split()]
money = 1000
stock = 0
p_today = prices[0]
for n in range(N-1):
    p_tomm = prices[n+1]
    if p_tomm >= p_today:
        n_stock = money // p_today
        stock += n_stock
        money = money - p_today * n_stock
        # while money >= p_today:
        #     stock += 1
        #     money -= p_today
    else:
        money += p_today * stock
        stock = 0
    p_today = p_tomm

if stock > 0:
    money += prices[-1] * stock

print(money)

Measured memory_bytes: 61884
MOD = 10**9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


n = int(input())
temp = [None]*n

for i,a in enumerate(map(int,input().split())):
  if temp[a-1] is None:
    temp[a-1] = i
  else:
    m = n - i + temp[a-1]
    break

s = n + 1
t = 1
print(n)

ik = 1
for k in range(n):
  t *= (m-k)*ik
  t %= MOD
  ik = modinv(k+2, MOD)
  s *= (n-k)*ik
  s %= MOD
  print((s-t)%MOD)


Measured memory_bytes: 13812
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define INF 0x3f3f3f3f

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

bool check(int n)
{
    bool flag=true;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            flag=false;
            break;
        }
    }
    return flag;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n;
    for(int i=n;;i++)
    {
        if(check(i))
        {
            cout<<i;
            break;
        }
    }    
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();

            int d = 0;
            for(int i = 0; i < n.Length; i++)
            {
                d = (d + int.Parse(n[i].ToString())) % 9;
            }
            if(d == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 32936
H,W = map(int,input().split())
grid = [[0 for w in range(W)] for h in range(H)]
sharps = []
for h in range(H):
  row = [v for v in input()]
  #print(row)
  for w,r in enumerate(row):
    #print(w,r)
    if r == "#":
      #grid[h][w] = "#"
      sharps.append([h,w])
      if h>=1:
        grid[h-1][w] += 1
        if w>=1:
          grid[h-1][w-1] += 1
        if w<=W-2:
          grid[h-1][w+1] += 1
      if h<=H-2:
        grid[h+1][w] += 1
        if w>=1:
          grid[h+1][w-1] += 1
        if w<=W-2:
          grid[h+1][w+1] += 1
      if w>=1:
        grid[h][w-1] +=1
      if w<=W-2:
        grid[h][w+1] +=1
#print(sharps)
for sharp in sharps:
  grid[sharp[0]][sharp[1]] = "#"
for g in grid:
  print("".join([str(v) for v in g]))

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC144
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            if (s[0] < 10 && s[1] < 10)
            {
                WriteLine(s[0] * s[1]);
            }
            else
            {
                WriteLine(-1);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

template<class T> inline bool chmin(T& to, T compare) {
    if (to > compare) {
        to = compare;
        return true;
    }
    return false;
};

template<class T> inline bool chmax(T& to, T compare) {
    if (to < compare) {
        to = compare;
        return true;
    }
    return false;
};

const llong MOD = 1e9 + 7;
const llong INF = 1e18;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N, W;
    cin >> N >> W;


    vecllong weight(N + 1, 0);
    vecllong value(N + 1, 0);
    llong maxValue = 0;

    FOR(i, N) {
        cin >> weight[i] >> value[i];
        maxValue += value[i];
    }

    vvecllong dp(N + 1, vecllong(maxValue + 1, INF));  // dp[i][value] = minWeight
    dp[0][0] = 0;

    FOR(i, N) {
        FOR(v, maxValue + 1) {
            if(v - value[i] >= 0) {
                dp[i + 1][v] = min({
                    dp[i][v - value[i]] + weight[i],
                    dp[i][v],
                    dp[i + 1][v]
                });
            } else {
                dp[i + 1][v] = dp[i][v];
            }
        }
    }

    llong ans = 0;

    for(llong v = maxValue; v >= 0; v--) {
        if(dp[N][v] <= W) {
            ans = v;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s,t = LS()
    r = ""
    for i in range(n):
        r += s[i] + t[i]

    return r


print(main())





Measured memory_bytes: 6604
#include<cstdio>
#define MOD 998244353

int n, s;
int dp[3003][3003];

int main() {
  scanf("%d %d", &n, &s);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j <= s; j++) {
      dp[i][j] = dp[i - 1][j] * 2 % MOD;
      if (j >= a) {
        dp[i][j] += dp[i - 1][j - a];
        dp[i][j] %= MOD;
      }
    }
  }
  printf("%d\n", dp[n][s]);
}


Measured memory_bytes: 36912
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long
const int MAXN = 2e5 +5;
int a[MAXN],b[MAXN];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int sum = 0;
    for(int i = 1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum = (sum + a[i]) % k;
        b[i] = (sum - i) % k;
        if(b[i] < 0) b[i] += k;
    }
    map<int,int> cnt;
    ll ans = 0;
    for(int i = 0;i<=n;i++)
    {
        if(i >= k) cnt[b[i-k]]--;
        ans += cnt[b[i]];
        cnt[b[i]]++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 11136
def main():
    K = int(input())
    if K%2 == 0 or K%5==0:
        return -1

    if K % 7 == 0:
        L = K * 9 // 7
    else:
        L = K * 9
    
    for i in range(1, 10000000):
        x = pow(10, i, L)
        if x == 1:
            return i
    else:
        return -1


if __name__ == "__main__":
    ans = main()
    print(ans)

Measured memory_bytes: 62944
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int INF = 1e9 + 10;
int main() {
  int n, m, c, s, g;
  while (cin >> n >> m >> c >> s >> g) {
    if (!n && !m && !c && !s && !g) {
      break;
    }

    // K[from][to][company]
    vector<vector<vector<int>>> K(
        n + 1, vector<vector<int>>(n + 1, vector<int>(c + 1, INF)));
    for (int i = 0; i < m; i++) {
      int x, y, d, comp;
      cin >> x >> y >> d >> comp;
      // bug:同じ区間に距離の違う同じ路線が存在することもある
      K[x][y][comp] = min(K[x][y][comp], d);
      K[y][x][comp] = min(K[x][y][comp], d);
    }
    for (int company = 1; company <= c; company++) {
      for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
          for (int j = 1; j <= n; j++) {
            if (K[i][j][company] > K[i][k][company] + K[k][j][company]) {
              K[i][j][company] = K[i][k][company] + K[k][j][company];
            }
          }
        }
      }
    }

    // 運賃を予め距離ごとに計算しておく
    vector<int> P(c);
    vector<vector<int>> fare(c + 1, vector<int>(200020));
    for (int i = 0; i < c; i++) {
      cin >> P[i];
    }
    for (int i = 0; i < c; i++) {
      vector<int> q(P[i]);
      for (int j = 0; j < P[i] - 1; j++) {
        cin >> q[j];
      }
      int now = 1;
      for (int j = 0; j < P[i]; j++) {
        int r;
        cin >> r;
        if (j == P[i] - 1) {
          for (; now < 200020; now++) {
            fare[i + 1][now] = fare[i + 1][now - 1] + r;
          }
        } else {
          for (; now <= q[j]; now++) {
            fare[i + 1][now] = fare[i + 1][now - 1] + r;
          }
        }
      }
    }

    // Floyd-Warshall
    vector<vector<int>> D(n + 1, vector<int>(n + 1, INF));
    for (int company = 1; company <= c; company++) {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
          if (K[i][j][company] != INF) {
            D[i][j] = min(D[i][j], fare[company][K[i][j][company]]);
          }
        }
      }
    }
    for (int k = 1; k <= n; k++) {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
          if (D[i][j] > D[i][k] + D[k][j]) {
            D[i][j] = D[i][k] + D[k][j];
          }
        }
      }
    }
    cout << (D[s][g] == INF ? -1 : D[s][g]) << endl;
  }
}



Measured memory_bytes: 21392
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;

int n;

long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)ans=ans+1LL*i*(i+1)/2;
	for(int i=1;i<=n-1;++i){
		int x,y;cin>>x>>y;
		ans-=1LL*min(x,y)*(n-max(x,y)+1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int a[100000];
    for(int i=0;i<x;i++){
        cin>>a[i];
    }
    sort(a,a+x);
    for(int i=0;i<x;i++){
        y=y-a[i];
    }
    cout<<y/a[0]+x<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n; i++){
			p[i] = sc.nextInt();
		}

		int cnt = 0;
		int flg = 0;
		if(p[0]>p[1]){
			flg = 0;
		}else{
			flg = 1;
		}
		for(int i=1;i<n-1;i++){
			if(flg==0 && p[i]>p[i+1]){
				cnt += 1;
				flg = 0;
			}else if(flg==0 && p[i]<p[i+1]){
				flg=1;
			}else if(flg==1 && p[i]>p[i+1]){
				flg=0;
			}else if(flg==1 && p[i]<p[i+1]){
				cnt +=1;
				flg = 1;
			}
		}
		System.out.println(cnt);

	}

}


Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MIN(a,b) ((a)<(b)?(a):(b))

#define POS(i,j) ((i)*n+(j))

void run(void){
  int n;
  scanf("%d",&n);
  int a[400];
  int i,j,k;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(n*n,sizeof(int64));
  for(i=2;i<=n;i++){
    for(j=0;j<n-i+1;j++){
      int64 min=1000000000LL*400*(401+1)/2;
      for(k=1;k<i;k++){
	min=MIN(min,dp[POS(j,k)]+dp[POS(j+k,i-k)]);
      }
      for(k=j;k<j+i;k++) min+=a[k];
      dp[POS(j,i)]=min;
    }
  }
  printf("%lld\n",dp[POS(0,n)]);
}

int main(void){
  run();
  return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll s; cin >> s;
    ll num = 1000000000;
    // num * div - mod = s;
    ll div,mod;
    div = (s + num -1)/num; //切り上げ
    mod = num * div - s;
    cout << "0 0 1000000000 1 " << mod << " " << div << endl;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-9;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)(n); i++)
#define Loop1(i, n) for(int i = 1; i <= (int)(n); i++)
#define Loopr(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < eps; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
bool inrange(vi xs, int t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	int q; cin >> q;
	Loop(unused, q) {
		int n, x; cin >> n >> x;
		int ans = 0;
		Loop(i, n - 1) {
			int xy = ((1 << 7) - 1);
			int y = xy ^ x;
			ans += xy;
			x = y;
		}
		ans += x;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int s, w; cin >> s >> w;
  if (s <= w) COUT("unsafe");
  else COUT("safe");
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int i;
	for (i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L') break;
		}
		else
		{
			if (s[i] == 'R') break;
		}
	}
	if (i == s.size()) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val (n,a,b,c) = readLine()!!.split(" ").map { it.toInt() }
    val queries = Array(n){""}
    val sets = Array(3){ TreeSet<Int>() }
    val arr = IntArray(3)
    val m = charArrayOf('A','B','C')
    val ans = CharArray(n)

    arr[0] = a
    arr[1] = b
    arr[2] = c

    for(i in 0 until n) {
        queries[i] = readLine()!!
        for(v in queries[i]) {
            val d = v - 'A'
            sets[d].add(i)
        }
    }

    for(i in 0 until n) {
        val q = queries[i]
        val l = q[0] - 'A'
        val r = q[1] - 'A'
        var select = -1

        if(arr[l] > arr[r]) {
            arr[l]--
            arr[r]++
            select = r
        } else if(arr[l]<arr[r]) {
            arr[l]++
            arr[r]--
            select = l
        } else  {
            val nl = sets[l].higher(i) ?: Int.MAX_VALUE
            val nr = sets[r].higher(i) ?: Int.MAX_VALUE
            if(nl < nr) {
                arr[r]--
                arr[l]++
                select = l
            } else {
                arr[r]++
                arr[l]--
                select = r
            }
        }
        if(arr[l] < 0 || arr[r] < 0) {
            print("No")
            return
        }
        ans[i] = m[select]
    }
    println("Yes")
    for(i in 0 until n) {
        println(ans[i])
    }
    // 서로 갯수가 같으면
    // 다음번에 나올 횟수가 가장 적은 녀석으로?


}

Measured memory_bytes: 79804
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < (vw[0].1 as usize) { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1 as usize;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1 as usize;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 411028
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a,b,c;

main(){
	cin>>a>>b>>c;
	if((a<c&&b>c)||(b<c&&a>c))dump("Yes");
	else dump("No");
}





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

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int n;
	cin >> n;
	string a, b ,c;
	cin >> a >> b >> c;
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == b[i] && b[i] == c[i]) {
			continue;
		}
		else if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) {
			ans += 2;
		}
		else {
			ans++;
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

C = Counter()
for _ in range(N):
    C[input()] += 1
ans = len(C)
print(ans)


Measured memory_bytes: 35552
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
 
 
using namespace std;

#define int long long
#define sc second
#define fr first
 
#define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
#define MAX 100000
#define NUM 101
 
llong n;
bool used[MAX];
typedef pair<int, int> pii; // (cst, to)
vector<pii> G[MAX];
 
int prim() {
    priority_queue<pii> que;
    fill(used, used + MAX, false);
    que.push(pii(0, 0));
    int ret = 0;
    while (!que.empty()) {
        int  v = que.top().second;
        int cst = (-1)*(que.top().first);
        que.pop();
        if (used[v]) continue;
        used[v] = true;
        ret += cst;
        for (int i = 0; i < G[v].size(); i++)
            que.push(pii((G[v][i].first)*(-1), (G[v][i].second)));
    }
    return ret;
}
signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    cin >> n;
    pii X[100001], Y[100001];

    for(int i=0; i<n; i++) {
      int a, b;
      cin >> a >> b;
      X[i] = pii(a, i);
      Y[i] = pii(b, i);
    }

    sort(X, X + n);
    sort(Y, Y + n);

    for(int i=0; i<n; i++) {
      if( i != n-1 ) {
	G[X[i].sc].push_back(pii(abs(X[i].fr - X[i + 1].fr), X[i + 1].sc));
	G[Y[i].sc].push_back(pii(abs(Y[i].fr - Y[i + 1].fr), Y[i + 1].sc));
      }
      if( i != 0 ) {
	G[X[i].sc].push_back(pii(abs(X[i].fr - X[i - 1].fr), X[i - 1].sc));
	G[Y[i].sc].push_back(pii(abs(Y[i].fr - Y[i - 1].fr), Y[i - 1].sc));
      }
    }
    
    /* for(int i=0; i<n-1; i++) {
      for(int j=i+1; j<n; j++) {
	if( i == j ) continue;
	G[j].push_back(pii(min(abs(X[i] - X[j]), abs(Y[i] - Y[j])), i));

      }
      }*/
    
    cout << prim() << endl;
 
    return 0;
}


Measured memory_bytes: 23660
#include <iostream>
#include <vector>
#include <map>

int main(int argc, char **argv)
{
    int N, M;
    std::map<std::string, int> s;
    std::map<std::string, int> t;

    std::cin >> N;
    for(int i = 0; i < N; i++){
        std::string str;
        std::cin >> str;
        s[str] = s[str] + 1;
    }
    
    std::cin >> M;
    for(int i = 0; i < M; i++){
        std::string str;
        std::cin >> str;
        t[str] = t[str] + 1;
    }

    int max = 0;
    for(auto it = s.begin(); it != s.end(); ++it){
        std::string key;
        key = it->first;
        int diff = s[key] - t[key];
        if(diff > max){
            max = diff;
        }
    }
    std::cout << max << std::endl;
}


Measured memory_bytes: 256