akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n;
   cin >> n;
   vector<int> v(n);
   
   for (int i = 0; i < n; i++) cin >> v[i];
   int sum = 0;
   for (auto it : v) sum += it;
   if (sum % 10 != 0) {
	   cout << sum << endl;
	   exit(0);
   }
	   int mx = 0;
	   for (int i = 0; i < n; i++){
		   if ((sum - v[i]) % 10 != 0){
			   mx = max(mx, sum - v[i]);  
			 }  
		 }  
		cout << mx << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Map<Integer,Integer>m=new TreeMap<Integer,Integer>();int t;for(Scanner s=new Scanner(System.in);s.hasNext();)m.put(t=s.nextInt(),m.containsKey(t)?m.get(t)+1:1);for(int i:m.keySet())if(m.get(i)==Collections.max(m.values()))System.out.println(i);}}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli a, b, c, x, y;
    lli ans = 1e18;
    cin >> a >> b >> c >> x >> y;
    for (lli i = 0; i < 3e5; i++) {
        lli xx = (x - i / 2);
        lli yy = (y - i / 2);
        lli cost = c * i;
        if (xx > 0) {
            cost += xx * a;
        }
        if (yy > 0) {
            cost += yy * b;
        }
        ans = min(cost, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC66();
}

void ABC66(){
    int i,j,count=0,n;
    string s;
    cin>>s;
    n=s.length();
    for(i=0;1;i++){
        n-=2;
        for(j=0;j<n/2;j++){
            if(s[j]==s[n/2+j])count++;
        }
        if(n/2==count)break;
        count=0;
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [0]
    B.extend(A)
    B.append(0)

    M = len(B)

    total = 0
    for i in range(M - 1):
        total += abs(B[i + 1] - B[i])

    ans = [0] * N
    for i in range(N):
        ans[i] = total - abs(B[i + 1] - B[i]) - abs(B[i + 2] - B[i + 1]) + abs(B[i + 2] - B[i])

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20480
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	cout << A.size() << endl;
	return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <string.h>

using namespace std;

int ball_list[10];
int right_val;      
int left_val;

bool flag;

void dfs(int right, int left){
  int count = right + left;
  int num = ball_list[count];

  if(flag) return;

  if(count == 10){
    flag = true;
  }else{
    if(right_val < ball_list[count]){
      right_val = num;
      dfs(right+1, left);
    }
    if(left_val < ball_list[count]){
      left_val = num;
      dfs(right, left+1);
    }
  }
}

int main(){
  int n;

  cin >> n;

  for(int i = 0; i < n; i++){
    flag = false;
    right_val = 0;
    left_val = 0;

    for(int j = 0; j < 10; j++){
      cin >> ball_list[j];
    }
    
    dfs(0, 0);

    cout << ((flag)? "YES" : "NO") << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
K=int(input())
lst=[1]
qqq=0
for i in range(K-1):
    if qqq==len(lst)-1:
        if lst[qqq]<9:
            lst[qqq]+=1
            for j in range(qqq-1,-1,-1):
                lst[j]=max(0,lst[j+1]-1)
            qqq=0
        else:
            lst=[0]*len(lst)+[1]
            qqq=0
    else:
        while qqq<len(lst)-1:
            if lst[qqq]<=lst[qqq+1] and lst[qqq]<9:
                break
            qqq+=1
        if qqq==len(lst)-1 and lst[qqq]==9:
            lst=[0]*len(lst)+[1]
            qqq=0
        else:
            lst[qqq]+=1
            for j in range(qqq-1,-1,-1):
                lst[j]=max(0,lst[j+1]-1)
            qqq=0
lst=list(map(str,lst[::-1]))
print("".join(lst))

Measured memory_bytes: 43760
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    mut a: [i64; n],
    }

    let mut ans: u64 = 0;

    let a_un_cnt = a.iter().filter(|x| **x < 0).count();
    let min = a.iter().map(|x| x.abs()).min().unwrap();
    let mut minflg = false;
    let mut minnum =0;

    if a_un_cnt % 2 == 0 {
        for i in 0..n {
            if a[i] < 0 {
                ans += a[i].abs() as u64;
            } else {
                ans += a[i] as u64;
            }
        }
    } else {
        for i in 0..n {
            if a[i].abs() == min && !minflg {
                minnum = a[i].abs() as u64;
                minflg = true;
            } else {
                if a[i] < 0 {
                    ans += a[i].abs() as u64;
                } else {
                    ans += a[i] as u64;
                }
            }
        }

        ans = ans - minnum;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,a,n) for(int i=a;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 1e3 + 5;
const int mod = 1e9;
int main()
{
    double t,d,s;cin>>d>>t>>s;
    (d/s <= t) ? cout<<"Yes" : cout<<"No";
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int i=a;i<b;i++)
#define repn(a,b,c) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


int n,m,q,a[101],b[101],c[101],d[101],A[100]={0};
int val=0,ans=0;
void solve(int ind,int minV){//current values and previous index assignment ie..min val of it's  assignment
    
    if(ind>n){
        val=0;
        f1(i,q+1){
            if(A[b[i]]-A[a[i]]==c[i]){
                val+=d[i];
            }            
        }
        if(val>ans){
            ans=val;
        }
        return;
    }
    for(int i=minV;i<=m;i++){
        A[ind]=i;
        solve(ind+1,i);
    }
    
}

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

    cin>>n>>m>>q;
    f1(i,q+1){
        cin>>a[i]>>b[i]>>c[i]>>d[i]; 
    }
    solve(1,1);
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  map<char,int>mp;
  mp['q']=0;
  mp['w']=0;
  mp['e']=0;
  mp['r']=0;
  mp['t']=0;
  mp['a']=0;
  mp['s']=0;
  mp['d']=0;
  mp['f']=0;
  mp['g']=0;
  mp['z']=0;
  mp['x']=0;
  mp['c']=0;
  mp['v']=0;
  mp['b']=0;
  mp['y']=1;
  mp['u']=1;
  mp['i']=1;
  mp['o']=1;
  mp['p']=1;
  mp['h']=1;
  mp['j']=1;
  mp['k']=1;
  mp['l']=1;
  mp['n']=1;
  mp['m']=1;
  string s;
  while(cin>>s){
    if(s=="#"){break;}
    for(int i=0; i<s.size(); i++ ){
      if(mp[s[i]]==1){s[i]='1';}
      else {s[i]='0';}
    }
    int cnt=0;
    for(int i=0; i<s.size()-1; i++){
      if(s[i]==s[i+1]){continue;}
      if(s[i]!=s[i+1]){cnt++;}
    }
    cout<<cnt<<endl;
  }
}

  


Measured memory_bytes: 3232
// AOJ 0655 Japan Sinks
// 2019.3.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 入力の高速化
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}


//// セグメント木
#define MAX (1<<17) //セグメント木のサイズ。2のべき乗にすべし
#define MIN(a, b)  ((a)<=(b)?(a):(b))
#define INF  0x7fffffff

int segMin[2 * MAX], segAdd[2 * MAX];

// 区間[a, b)に値xを加算する
// int k = 0, int l = 0, int r = MAX
void add(int a, int b, int x, int k, int l, int r)
{
	if (r <= a || b <= l) return;

	if (a <= l && r <= b) {
		segAdd[k] += x;
		return;
	}
	add(a, b, x, (k << 1) + 1, l, (l + r) >> 1);
	add(a, b, x, (k << 1) + 2, (l + r) >> 1, r);
	segMin[k] = MIN(segMin[(k << 1) + 1] + segAdd[(k << 1) + 1], segMin[(k << 1) + 2] + segAdd[(k << 1) + 2]);
}

//  int k = 0, int l = 0, int r = MAX
int getMin(int a, int b, int k, int l, int r)
{
	int le, ri;

	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return (segMin[k] + segAdd[k]);
	le = getMin(a, b, (k << 1) + 1, l, (l + r) >> 1);
	ri = getMin(a, b, (k << 1) + 2, (l + r) >> 1, r);
	return MIN(le, ri) + segAdd[k];
}


//// 座標圧縮
// ソート済データのユニーク化（=重複データを取り除く）
//　　　データの個数、ソート済データ配列
int uniq(int n, int *a)
{
	int i, j;

	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i + 1;	// ユニーク化後のデータ個数。データは元の配列に格納
}

// バイナリサーチ
//    ソート済データ配列、探したいデータ、上限位置（わからなければ、データ配列の大きさでOK）
int bsch(int *a, int x, int r)
{
	int m, l = 0;

	while (l < r) {
		m = (l + r) >> 1;
		if (a[m] < x) l = m + 1; else r = m;
	}
	return l;        // データ配列での位置
}

// C言語標準装備のクイックソート用比較関数。整数(int)配列を昇順にソート
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

// 座標圧縮の本体
// 　　圧縮した新しいデータ、データ数、１次元データ配列
int compact(int n, int *a)
{
	int i, j, k;
	int *memo;

	if ((memo = malloc(sizeof(int)*n)) == NULL) return 0;    // メモリ確保に失敗
	memcpy(memo, a, sizeof(int)*n);
	qsort(memo, n, sizeof(int), cmp);
	k = uniq(n, memo);
	for (i = 0; i < n; i++) {
		j = bsch(memo, a[i], k);
		a[i] = j;
	}
	free(memo);
	return 1;    // 正常終了時
}


//// 本問題関連
int A[100005]; int N;         // 入力データ
int stack[100005]; int top;   // スタック

int main()
{
	int i;

	N = in();
	for (i = 1; i <= N; i++) A[i] = in();
	A[0] = A[N + 1] = 0;     // 両側の外に0をつけて、余計なことを考えずに済む
	N += 2;

	compact(N, A);   // 座標が大きすぎるので、圧縮しておく。最大値が10万以下になる。
//for (i = 0; i < N; i++) printf("%d ", A[i]); printf("\n");

	// 定番のスタックを使い、上下の変化を記録。
	// 上がったところの高さをスタックにしまい、下がったところでスタックのトップにある
	// 高さとの空間をセグメント木に -1 として追加する。
	// -1とした理由は最大値を取るため。用意したセグメント木は最小値にしか対応していないので。
	top = 0; for (i = 1; i < N; i++) {
		if (A[i - 1] > A[i]) add(A[i], stack[--top], -1, 0, 0, N);
		if (A[i-1] != A[i]) stack[top++] = A[i];
	}

	printf("%d\n", -getMin(0, N, 0, 0, N));  // 最小値を最大値に変える
	return 0;
}


Measured memory_bytes: 3868
/*=======================================
 * Author : ylsoi
 * Problem : ARC80F
 * Algorithm : Graph Matching and Greed
 * Time : 2018.7.16
 * ===================================*/
#include<bits/stdc++.h>

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
    freopen("ARC80F.in","r",stdin);
    freopen("ARC80F.out","w",stdout);
}

const int maxn=500+10;
int n,a[maxn],pos[maxn],tot,cnt,ans;
int be[maxn],cnte,to[maxn*maxn],las[maxn*maxn],beg[maxn];
bool vis[maxn];

void add(int u,int v){
    las[++cnte]=beg[u];
    beg[u]=cnte;
    to[cnte]=v;
}

bool pd(int x){
    if(x==1 || x==2)return false;
    int y=sqrt(x);
    REP(i,2,y)if(x%i==0)return false;
    return true;
}

bool Hungary(int u){
    for(int i=beg[u];i;i=las[i]){
        if(vis[to[i]])continue;
        vis[to[i]]=1;
        if(!be[to[i]] || Hungary(be[to[i]])){
            be[to[i]]=u;
            return true;
        }
    }
    return false;
}

int main(){
    scanf("%d",&n);
    REP(i,1,n){
        scanf("%d",&a[i]);
        if(i==1 || a[i-1]<a[i]-1)pos[++tot]=a[i];
        if(i!=1 && a[i]>a[i-1]+1)pos[++tot]=a[i-1]+1;
    }
    pos[++tot]=a[n]+1;
    REP(i,1,tot)if(pos[i]%2)++cnt;
    REP(i,1,tot)if(pos[i]%2==0){
        REP(j,1,tot)if(pos[j]%2==1 && pd(abs(pos[j]-pos[i])))
            add(i,j);
    }
    REP(i,1,tot)if(pos[i]%2==0){
        memset(vis,0,sizeof(vis));
        ans+=Hungary(i);
    }
    printf("%d\n",ans+(tot-ans*2)+(cnt-ans)%2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int ans = 0;
        int[][] a = new int[n][m];
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += b[j] * a[i][j];
            }
            if (sum + c > 0)
                ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, A, B; cin >> N >> A >> B;

    while(true){
        if(A+1 < B) A++;
        else if(A-1 == 0){
            cout << "Borys" << endl;
            return 0;
        }
        else A--;

        if(B-1 > A) B--;
        else if(B+1 == N+1){
            cout << "Alice" << endl;
            return 0;
        }
        else B++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl

const int max_E = 6000;
const int max_V = 3000;
struct edge{int from,end,cost;};
edge es[max_E];
int d[max_V];
int V,E;

void BellmanFord(int s){
    for(int i=0;i<V;i++)d[i]=INF;
    d[s]=0;
    int endV;
    for(int j=0;j<2*V+1;j++){
        if(j==V){
            endV=d[V-1];
        }
        if(V<j && j<=2*V){
            if(endV==d[V-1]){
                //無
            }else{
                d[V-1]=-INF;
                break;
            }
        }
        bool update=false;
        for(int i=0;i<E;i++){
            edge k=es[i];
            if(d[k.from]!=INF && d[k.end]>d[k.from]+k.cost){
                d[k.end]=d[k.from]+k.cost;
                update=true;
            }
        }
        //REP(k,V){cout << d[k] << " ";}cout << endl;
        if(!update)break;
    }
}


signed main(void){
    int N,M,P;
    int A[5141],B[5141],C[5141];
    cin >> N >> M >> P;
    REP(i,M){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;B[i]--;
    }
    
    edge h;
    REP(i,M){
        h.from=A[i];
        h.end=B[i];
        h.cost=-C[i]+P;
        es[i]=h;
    }
    V=N;E=M;
    BellmanFord(0);
    if(d[N-1]==-INF){
        cout << -1 << endl;
    }else{
        cout << max(-d[N-1],0ll) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 512
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = 1
temp = 10**5
for i in range(n):
  T = t - h[i]*0.006
  if abs(a - T) < temp:
    temp = abs(a - T)
    ans = i+1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
int main(void){
    int D;
    scanf("%d",&D);
    if(D==25){
        printf("Christmas\n");
    }else if(D==24){
        printf("Christmas Eve");
    }else if(D==23){
        printf("Christmas Eve Eve\n");
    }else if(D==22){
        printf("Christmas Eve Eve Eve\n");
    }
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N, Wmax;
vector<int> W, V;
vector<vector<long long>> DP;

int main() {
	cin >> N >> Wmax;
	W.resize(N + 1);
	V.resize(N + 1);
	for (int n = 1; n <= N; n++) {
		cin >> W[n] >> V[n];
	}
	DP.resize(N + 1, vector<long long>(100001,(1e9)*100));
	DP[0][0] = 0;
	for (int n = 1; n <= N; n++) {
		for (int v = 0; v < V[n]; v++)DP[n][v] = DP[n - 1][v];
		for (int v = V[n]; v <= 100000; v++) {
			DP[n][v] = min(DP[n - 1][v], DP[n - 1][v - V[n]] + W[n]);
		}
	}
	long long ans = 0;
	for (int v = 0; v <= 100000;v++) {
		if (DP[N][v] <= Wmax)ans = v;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            var abc = ReadAndParseIntArr();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];
            var list = new List<int>();
            list.Add(a);
            list.Add(b);
            list.Add(c);
            list.Sort();
            int ans = list[2] * 10 + list[1] + list[0];
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
box = [[[0]*10 for i in range(3)] for j in range(4)]
num = int(input())
for i in range(num):
    temp = list(map(int, input().split()))
    box[temp[0]-1][temp[1]-1][temp[2]-1] += temp[3]
    if box[temp[0]-1][temp[1]-1][temp[2]-1] < 0: box[temp[0]-1][temp[1]-1][temp[2]-1] = 0

for i in range(len(box)):
    [print(" "+" ".join( map(str, box[i][j])) ) for j in range(len(box[i]))]
    if i != 3:
        print("####################")

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int m[2], d[2];
	cin >> m[0] >> d[0] >> m[1] >> d[1];
	if(m[1]==m[0]+1) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    int n, ans;
    cin >> n;
    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    ans = 0;
    sort(l.begin(), l.end(), greater<>());
    for(int i = 0; i < n-2; i++){
        for(int j = i+1; j < n-1; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] < l[j]+l[k] && l[j] < l[i]+l[k] && l[k] < l[i]+l[j]) ans++;
                    else break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#include "atcoder/all"
#else
#define NDEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
#endif

using namespace std;
using namespace atcoder;
using large = long long;

static void solve() {
    large n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
}

int main()
{
    int t;
    cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,b,n,ans;
	cin>>n>>a>>b;
	ans=n/(a+b)*a;
	if(n%(a+b)<=a) ans+=n%(a+b);
	if(n%(a+b)>a) ans+=a;
	cout<<ans<<endl;return 0;
}

Measured memory_bytes: 256
#Match Matching
n,m=map(int,input().split())
a=list(map(int,input().split()))
lst=[0,2,5,5,4,5,6,3,7,6]
a.sort()
dp=[[0]*(n+1) for i in range(m)]
dq=[[""]*(n+1) for j in range(m)]
x=lst[a[0]]
for i in range(1,n+1):
    if i%x==0:
        dp[0][i]=dp[0][i-x]+1
        dq[0][i]=dq[0][i-x]+str(a[0])
for i in range(1,m):
    x=lst[a[i]]
    for j in range(1,n+1):
        if j<x:
            dp[i][j]=dp[i-1][j]
            dq[i][j]=dq[i-1][j]
        elif j==x:
            if dp[i-1][j]>1:
                dp[i][j]=dp[i-1][j]
                dq[i][j]=dq[i-1][j]
            else:
                dp[i][j]=1
                dq[i][j]=str(a[i])
        else:
            if dp[i][j-x]==0:
                dp[i][j]=dp[i-1][j]
                dq[i][j]=dq[i-1][j]
            else:
                if dp[i-1][j]>dp[i][j-x]+1:
                    dp[i][j]=dp[i-1][j]
                    dq[i][j]=dq[i-1][j]
                elif dp[i][j-x]!=0:
                    dp[i][j]=dp[i][j-x]+1
                    dq[i][j]=dq[i][j-x]+str(a[i])
h=list(map(int,list(dq[m-1][n])))
h.sort(reverse=True)
h=list(map(str,h))
print("".join(h))

Measured memory_bytes: 68032
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	ll n, m, ans;
	cin >> n >> m;
	if(abs(n-m)>1) ans=0;
	else if(n==m)
	{
		ans=1;
		ans*=2;
		reps(i, n)
		{
			ans*=i;
			ans%=MOD;
			ans*=i;
			ans%=MOD;
		}
	}
	else
	{
		if(n>m) swap(n, m);
		ans=1;
		reps(i, n)
		{
			ans*=i;
			ans%=MOD;
			ans*=i;
			ans%=MOD;
		}
		ans*=m;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    cnt = 0
    col = set()
    for a in A:
        if a>=3200:
            cnt += 1
        else:
            col.add(a//400)
    print(max(1,len(col)), len(col)+cnt)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38464
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * We are to guess an integer n
 * 1	Yes for sure
 * 10	If I get a no it has to be from 2 to 9 else it can be 1 or >= 10
 */
const ll N = 1LL * 100000 * 100000;
int main() {
	ll i = 10;
	char ch;
	while(true) {
		cout << "? " << i << endl;
		cin >> ch;
		if (ch == 'Y') {
			i *= 10;
		}
		else {
			ll lo = i / 10 + 1, hi = i - 1, ans = -1;
			while(lo <= hi) {
				ll mid = (lo + hi) / 2;
				cout << "? " << mid * 10 << endl;
				cin >> ch;
				if (ch == 'Y') {
					ans = mid;
					hi = mid - 1;
				}
				else {
					lo = mid + 1;
				}
			}
			cout << "! " << ans << endl;
			return 0;
		}
		if (i == N) {
			break;
		}
	}
	while(i > 1) {
		cout << "? " << i - 1 << endl;
		cin >> ch;
		if (ch == 'N') {
			cout << "! " << i << endl;
			return 0;
		}
		i /= 10;
	}
	cout << "! " << 1 << endl;
}


Measured memory_bytes: 596
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, K, Q = map(int, readline().split())
base = 0
P = [K]*N
for i in range(Q):
    a = int(readline())
    P[a-1] += 1
    base += 1
for i in range(N):
    if P[i] <= base:
        write("No\n")
    else:
        write("Yes\n")

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

long long n, w, dp[110][100100], a[110], b[110], ans = 0, sum = 0;

int main(){
	
	scanf("%lld %lld", &n, &w);
	
	for(int i = 0; i < n; i++) {scanf(" %lld %lld", &a[i], &b[i]); sum += b[i];}
	
	for(int i = 0; i < n + 1; i++) for(int j = 0; j < 100010; j++) dp[i][j] = 1000000000 * (j != 0);
	
	dp[0][b[0]] = a[0];
	if(dp[0][b[0]] <= w) ans = max(b[0], ans);
	
	for(int i = 1; i < n; i++){
		for(long long j = 0; j <= sum; j++){
			
			if(j < b[i]) {dp[i][j] = dp[i - 1][j];}
			else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - b[i]] + a[i]);
			
			if(dp[i][j] <= w && j != 0) ans = max(j, ans);
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 82768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		
		int[] d = new int[N];
		
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			d[i] = Math.abs(a - X);
		}
		
		int x = d[0];
		
		for(int i = 1; i < N; i++) {
			x = gcd(x, d[i]);
		}
		System.out.println(x);
	}
	
	public static int gcd(int a, int b) {
		if(b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
}


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

bool flag[500000];
int n;
string str[100001];
int cal[5];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> str[i];
	}
	cal[0]=1;
	for(int i=1;i<5;i++){
		cal[i]=cal[i-1]*26;
	}
	int len=1;
	while(1){
		memset(flag,false,sizeof(flag));
		for(int i=0;i<n;i++){
			int hash=0;
			if(str[i].size()<len)continue;
			for(int j=0;j<len;j++){
				hash=hash*26+(str[i][j]-'a');
			}
			flag[hash]=true;
			for(int j=len;j<str[i].size();j++){
				hash-=(str[i][j-len]-'a')*cal[len-1];
				hash=hash*26+(str[i][j]-'a');
				flag[hash]=true;
			}
		}
		for(int i=0;i<cal[len];i++){
			if(!flag[i]){
				string res="";
				int g=i;
				for(int j=0;j<len;j++){
					res+='a'+(g/cal[len-j-1]);
					g%=cal[len-j-1];
				}
				cout << res << endl;
				return 0;
			}
		}
		len++;
	}
	return 0;
}

Measured memory_bytes: 8716
#include<iostream>

using namespace std;

bool map[100][100];

int n, w, h, s, t;

int main() {
    while(1) {
        cin >> n;
        if (n == 0) break;
        cin >> w >> h;

        for (int i = 0 ; i < w; ++i)
            for (int j = 0; j < h; ++j)
                map[i][j] = false;
        
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            x--; y--;
            map[x][y] = true;
        }
        //for (int i = 0 ; i < w; ++i) {
        //    for (int j = 0; j < h; ++j) {
        //        cout << (map[i][j] ? '*' : '.');
        //    }
        //    cout << endl;
        //}

        cin >> s >> t;

        int maxp = 0;
        for (int i = 0; i + s <= w; ++i) {
            for (int j = 0; j + t <= h; ++j) {
                int p = 0;
                for (int x = i; x < i + s; ++x) {
                    for (int y = j; y < j + t; ++y) {
                        if (map[x][y]) p++;
                    }
                }
                //cout << i << ", " << j << " cnt = " << p << endl;
                if (p > maxp) maxp = p;
            }
        }

        cout << maxp << endl;
    }
}

Measured memory_bytes: 2996
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [[0]*2 for i in range(M+N)]
for i in range(M):
  B[i] = list(map(int, input().split()))
for i in range(N):
  B[M+i] = [1, A[i]]
B=sorted(B ,key=lambda x:x[1],reverse=True)
i = 0
cnt = 0
ans = 0
while(cnt < N):
  if(cnt + B[i][0] < N):
    ans += B[i][0] * B[i][1]
    cnt += B[i][0]
  else:
    ans += (N - cnt) * B[i][1]
    cnt = N
  i += 1
print(ans)

Measured memory_bytes: 47020
#include <map>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

enum state{
  unknown = -1,
  same = 0,
  up = 1,
  down = 2
};

int main(){
  const int n = getInt();
  vector<state> s;

  map<int, map<int, int> > two;
  map<int, map<int, map<int, int> > > three;

  three[up][same][down] = 1;
  three[down][same][up] = 2;
  three[up][same][up] = 3;
  three[down][same][down] = 3;
  two[up][down] = 4;
  two[down][up] = 5;

  int ans[6] = {0};
  int prev = 0;
  REP(i,n){
    const int a = getInt();

    if(i){
      state next = unknown;
      if(prev < a) next = up;
      if(prev == a) next = same;
      if(prev > a) next = down;

      if(s.empty() || s.back() != next){
        s.push_back(next);

      const int m = s.size();
      if(m >= 2){
        ans[two[s[m - 2]][s[m - 1]]]++;
      }
      if(m >= 3){
        ans[three[s[m - 3]][s[m - 2]][s[m - 1]]]++;
      }
      }
    }

    prev = a;
  }

  REP(i,5)
    printf("%d%c", ans[i + 1], i == 4 ? '\n' : ' ');

  return 0;
}


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


Measured memory_bytes: 20052
import copy
H,W,K=map(int,input().split())
c=[]
ANS=0
for i in range(H):
    c.append(list(input()))
for i in range(2**H):
    for j in range(2**W):
        C=copy.copy(c)
        ans=0
        for k in range(H):
            if (i>>k)&1==1:
                C[k]=['.' for i in range(W)]
        for l in range(W):
            if (j>>l)&1==1:
                C=list(zip(*C))
                C[l]=['.' for i in range(H)]
                C=list(zip(*C))
        for s in C:
            for a in s:
                if a=='#':
                    ans+=1
        if ans==K:
            ANS+=1
print(ANS)

Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    int tmp_n;
    vector<int> num(1010);
    for ( int i = 1; i <= n; ++i ) {
        tmp_n = i;
        for ( int j = 2; j <= tmp_n; ++j ) {
            while ( tmp_n % j == 0 ) {
                ++num[j];
                tmp_n /= j;
            }
        }
    }
    ll ans = 1;
    for ( int i = 1; i <= 1000; ++i ) ans = ans * (num[i]+1) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=100000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 233333;
int T;

string str;

int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    cin >> T;
    T =1;
    while(T--)
    {
        cin >>str;
        int n = str.size();
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            ans += str[i]-'0';
        }
        if (ans % 9 ) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= x; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define REPZ(i, x) for (int i = 0; i <= x; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
using namespace std;
#define DUMPOUT cerr
// vector
template < typename T > istream &operator>>(istream &is, vector< T > &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// pair
template < typename T, typename U >
ostream &operator<<(ostream &os, pair< T, U > &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template < typename T >
ostream &operator<<(ostream &os, const vector< T > &vec) {
  os << "{";
  REP(i, (int)vec.size())
  os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
  os << "}";
  return os;
}
// map
template < typename T, typename U >
ostream &operator<<(ostream &os, map< T, U > &map_var) {
  os << "{";
  FORA(itr, map_var) {
    os << *itr;
    itr++;
    if (itr != map_var.end())
      os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template < typename T > ostream &operator<<(ostream &os, set< T > &set_var) {
  os << "{";
  FORA(itr, set_var) {
    os << *itr;
    itr++;
    if (itr != set_var.end())
      os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { DUMPOUT << endl; }
template < class Head, class... Tail >
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if (sizeof...(Tail) > 0)
    DUMPOUT << ", ";
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define DUMP(...)                                                              \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                              \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl  \
          << "    ",                                                           \
      dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define DUMP(...)
#endif

#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN
//----//
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;
  if (A <= 9 && B <= 9)
    print(A * B);
  else
    print(-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
struct point {int x; int y;};
bool operator <(const point& a, const point& b) {return std::tie(a.y, a.x) > std::tie(b.y, b.x);}

int N;
point points[200005];
int UL[200005]; int UR[200005];
int DL[200005]; int DR[200005];
int two[200005];

const int mod = 998244353;

void add(int &ans, int dod) {
    ans = (ans % mod + dod % mod) % mod;
}

int mul(long long a, long long b, long long c = 1, long long d = 1) {
    a = (two[a] % mod + mod - 1) % mod;
    b = (two[b] % mod + mod - 1) % mod;
    c = (two[c] % mod + mod - 1) % mod;
    d = (two[d] % mod + mod - 1) % mod;
    return a * b % mod * c % mod * d % mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> points[i].x >> points[i].y;

    sort(points + 1, points + N + 1);

    ordered_set s;

    int j = 1;
    for(int i = 1; i <= N; i++) {
        while(j <= N && points[i].y == points[j].y)
            s.insert(points[j++].x);
        int ord = s.order_of_key(points[i].x);
        UL[i] = ord;
        UR[i] = s.size() - ord - 1;
    }

    s.clear();
    j = N;
    for(int i = N; i >= 1; i--) {
        while(j >= 1 && points[i].y == points[j].y)
            s.insert(points[j--].x);
        int ord = s.order_of_key(points[i].x);
        DL[i] = ord;
        DR[i] = s.size() - ord - 1;
    }

    two[0] = 1;
    for(int i = 1; i <= N; i++)
        two[i] = (two[i - 1] * 2LL) % mod;

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        add(ans, mul(UL[i], DR[i]));
        add(ans, mul(DL[i], UR[i]));
        
        add(ans, mul(UL[i],UR[i], DR[i]));
        add(ans, mul(UR[i],DR[i], DL[i]));
        add(ans, mul(DR[i],DL[i], UL[i]));
        add(ans, mul(DL[i],UL[i], UR[i]));

        add(ans, mul(DL[i], UL[i],DR[i], UR[i]));

        add(ans, two[N - 1]);
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v.push_back(a[i]);
    }

    sort(v.begin(), v.end());

    for (int i = 0; i < n; i++) {
        if ( v[n-1] == a[i]) {
            cout << v[n-2] << endl;
        } else {
            cout << v[n-1] << endl;
        }
    }
}

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  vector<int> ke;
  int da;
  string st;
  while(1){
    ke.erase(ke.begin(),ke.end());
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> da;
      ke.push_back(da);
    }
    cin >> st;
    int j=0;
    for(int i=0;i<st.size();i++){
      for(int k=0;k<ke[j];k++){
	st[i]--;
	if(st[i]=='a'-1)st[i]='Z';
	else if(st[i]=='A'-1)st[i]='z';
      }
      /* if(ke[j]<=26){
	if(st[i]>='A'&&st[i]<='Z'){
	  if(st[i]-ke[j]<'A'){
	    st[i]='z'+1+st[i]-'A';
	  }
	}
	if(st[i]>='a'&&st[i]<='z'){
	  if(st[i]-ke[j]<'a'){
	    st[i]='Z'+1+st[i]-'a';
	  }
	}
	key=
      }
      st[i]-=key;*/
      j++;
      if(j==n)j=0;
    }
    cout << st << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,ans=0;
	in(n);
	vll a(n);
	pair<ll, ll> tmp=make_pair(1000000001,-1);
	in(a[0]);
	rep(i, 1, n) {
		in(a[i]);
		if (a[i - 1] < 0) {
			a[i - 1] *= -1;
			a[i] *= -1;
		}
		if (tmp.first > a[i - 1]) {
			tmp.first = a[i - 1];
			tmp.second = i - 1;
		}
	}
	if (a[n - 1] < 0) {
		if (a[n - 1] * -1 > tmp.first) {
			a[n - 1] *= -1;
			a[tmp.second] *= -1;
		}
	}

	rep(i, 0, n) {
		ans += a[i];
	}
	outn(ans);
	return 0;

}


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

int main(){
  string y[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int num[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};

  while(1){
    int m,d;
    cin >> m >> d;
    if( m == 0 && d == 0 ) break;
    while( m != 0 ){
      d += num[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }

  return 0;
}

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

int main() {
	int N, C;
	cin >> N >> C;
	vector<vector<int>> D(C,vector<int>(C)), c(N,vector<int>(N));
	for(int i=0;i<C;i++) {
		for(int j=0;j<C;j++) {
			cin >> D[i][j];
		}
	}
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			cin >> c[i][j];
			c[i][j]--;
		}
	}
	vector<vector<int>> rest(N,vector<int>(N));
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			rest[i][j] = ((i+1) + (j+1)) % 3;
		}
	}
	// color[3で割ったあまり][色(0<n<C)]
	vector<vector<int>> color(3, vector<int>(C, 0));
	for(int i=0;i<N;i++) {
		for(int j=0;j<N;j++) {
			if(rest[i][j] == 0) color[0][c[i][j]]++;
			if(rest[i][j] == 1) color[1][c[i][j]]++;
			if(rest[i][j] == 2) color[2][c[i][j]]++;
		}
	}

	int ans = INT_MAX;
	// C色の中から3色(i, j, k)を選ぶ
	for(int i=0;i<C;i++) {
		for(int j=0;j<C;j++) {
			if(i == j) continue;
			for(int k=0;k<C;k++) {
				int tmpsum = 0;
				if(i == k or j == k) continue;
              	// i, j, kが全て異なるとき
              	// 3で割ったあまりが0 -> 色をiに
             	 // 3で割ったあまりが1 -> 色をjに
             	 // 3で割ったあまりが2 -> 色をkに
				for(int l=0;l<C;l++) tmpsum += (color[0][l]) * D[l][i];
				for(int l=0;l<C;l++) tmpsum += (color[1][l]) * D[l][j];
				for(int l=0;l<C;l++) tmpsum += (color[2][l]) * D[l][k];
				ans = min(ans, tmpsum);
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define mod 998244353
using namespace std;
void solve()
{
	ll n,x,y;
	cin >> n >> x >> y;
	ll arr[n+1][n+1];
	ll ans[n];
	memset(ans,0,sizeof(ans));
	for(ll i=1;i<=n;i++)
		for(ll j=i+1;j<=n;j++)
		{
			ll dist = abs(j-x)+abs(i-y)+1;
			dist = min(dist,abs(j-y)+abs(i-x)+1);
			arr[i][j]=min(abs(j-i),dist);
			ans[arr[i][j]]++;
		}
	for(ll i=1;i<n;i++)
		cout << ans[i]<<"\n";
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 31104
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}

Measured memory_bytes: 4352