akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

struct d {
  double x, y, dx, dy;
};
vector<d> data;

double calc(double k){
  double xmax=-1e10;
  double ymax=-1e10;
  double xmin=1e10;
  double ymin=1e10;

  for(auto&& d:data){
    xmax = max(d.x+d.dx*k, xmax);
    ymax = max(d.y+d.dy*k, ymax);
    xmin = min(d.x+d.dx*k, xmin);
    ymin = min(d.y+d.dy*k, ymin);
  }
  // cerr << "calc " << k << " " << xmax << " " << xmin << " " << ymax << " " << ymin << endl;
  return (xmax - xmin) * (ymax - ymin);
}

double f(int l, int r) {
  int m = (l + r) / 2;
  double cl = calc(l/2.0), cr = calc(r/2.0), cm = calc(m/2.0);
  // cerr << l << " " << r << " " << cl << " " << cm << " " << cr << endl;
  if(r - l <= 1)return cm;

  if(cl <= cm && cm <= cr)return f(l, m);
  if(cl > cm && cm > cr)return f(m, r);
  else return min(f(l, m), f(m, r));
}

int main() {
  int n;
  cin >> n;
  data.resize(n);
  for (auto&& x : data) {
    char d;
    cin >> x.x >> x.y >> d;
    if (d == 'U') {
      x.dy = 1;
      x.dx = 0;
    }
    if (d == 'D') {
      x.dy = -1;
      x.dx = 0;
    }
    if (d == 'L') {
      x.dy = 0;
      x.dx = -1;
    }
    if (d == 'R') {
      x.dy = 0;
      x.dx = 1;
    }
  }
  cout << fixed << setprecision(10) << f(0, 2e8) << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };

int cal(int x){
	int count=0;
	while(true){
		if(x % 2 != 0) break;
		x=x/2;
		count++;
	}
	return count;
}

int main() {
	int n;
	int a;
	int b[205];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		b[i]=cal(a);
	}
	sort(b,b+n);
	cout<<b[0]<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long  XORsum(long long a)
{
    long long ans;
    // switch (a % 4)
    // {
    // case 0:
    //     ans = a;
    //     break;
    
    // case 1:
    //     ans = 1;
    //     break;

    // case 2:
    //     ans = 1 + a;
    //     break;

    // case 3:
    //     ans = 0;
    //     break;
    // }
    if (a % 4 == 0) ans = a;
    if (a % 4 == 1) ans = 1;
    if (a % 4 == 2) ans = 1 + a;
    if (a % 4 == 3) ans = 0;
    return ans;

}

int main(int argc, char const *argv[])
{
    long long A, B;
    cin >> A >> B;
    A--;
    long long sumA = XORsum(A);
    long long sumB = XORsum(B);

    cout << (sumB ^ sumA) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
typedef long long ll;

using namespace std;

ll n, a, b;
ll dp[2005];

int main() {
	cin >> n;
	for (int i = 3; i < 10; i++) {
		dp[n - i] = 1;
	}
	dp[n] = 1;
	for (int i = n-2; i >= 0; i--){
		for (int j = 3; j < 10; j++){
			dp[i - j] = (dp[i - j + 1] + dp[i])%1000000007;
		}
	}
	cout << dp[0];
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 2e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll BIT[N];
void update(ll x,ll val){
  for(;x<=2e5;x+=(x&-x)){
    BIT[x] = max(BIT[x],val);
  }
}

ll query(ll x){
  ll val = 0;
  for(;x>0;x-=(x&-x)){
    val = max(val,BIT[x]);
  }
  return val;
}

int main(int argc, char const *argv[])
{    
  #ifdef LOCAL_TEST
  freopen("in.txt","r",stdin);
  //freopen("out.txt", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #endif
    

  ll n; 
  cin >> n;

  ll h[n+1],a[n+1];
  FOR(i,1,n)cin >> h[i];
  FOR(i,1,n)cin >> a[i];

  ll dp[n+1];
  dp[h[1]] = a[1];
  update(h[1],a[1]);
  FOR(i,2,n){
    dp[h[i]] = a[i] + query(h[i]-1);
    update(h[i],dp[h[i]]);
  } 

  ll ans = 0;
  FOR(i,1,n)ans = max(ans,dp[h[i]]);

  cout << ans;

  return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define INF 2001
#define MAX 101

using namespace std;

int MAT[MAX][MAX];
int N;

int prim(){
    int sum;
    bool complete[MAX];
    int dist[MAX];
    int parent[MAX];
    
    for (int i = 0; i < N; i++) {
        complete[i] = false;
        dist[i] = INF;
        parent[i] = -1;
    }
    
    dist[0] = 0;
    
    while (1) {
        int u = -1;
        int min = INF;
        
        for (int i = 0; i < N; i++) {
            if (min > dist[i] && !complete[i]) {
                u = i;
                min = dist[i];
            }
        }
        
        if (u == -1) break;
        
        complete[u] = true;
        
        for (int v = 0; v < N; v++) {
            if (!complete[v] && MAT[u][v] != INF) {
                if (dist[v] > MAT[u][v]) {
                    dist[v] = MAT[u][v];
                    parent[v] = u;
                }
            }
        }
    }
    
    sum = 0;
    
    for (int i = 1; i < N; i++) {
        sum += MAT[parent[i]][i];
    }
    
    return sum;
}

int main(){
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d",&MAT[i][j]);
            if (MAT[i][j] == -1) MAT[i][j] = INF;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}

Measured memory_bytes: 1284
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,l; cin >> n >> l;
    VI list(n); REP(i,n) list[i] = l+i;
    int minus = INF , tmp = INF;
    REP(i,n) if(abs(list[i])<tmp){minus = list[i]; tmp = abs(list[i]);}
    out(SUM(list,0LL)-minus);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        sc.close();
        System.out.println(new Main().roller_coaster(k, h));

    }

    public int roller_coaster(int k, int[] h){
        int count = 0;
        for(int height : h){
            if(height >= k){
                count++;
            }
        }
        return count;
    }
}


Measured memory_bytes: 48596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
  public static void main(String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    int n = str.length();
    System.out.println("" + str.charAt(0) + (n-2) + str.charAt(n-1));
  }
}

Measured memory_bytes: 36932
#include<stdio.h>

int max(int a, int b){
  return (a > b ? a : b);
}

int min(int a, int b){
  return (a > b ? b : a);
}

int digits_of(long long n){
  int d = 1;
  while((n /= 10) != 0) d++;
  return d;
}

int main(){
  long long N;
  scanf("%lld", &N);
  
  int F = digits_of(N);
  int A, B;
  for(A = 2; (long long)A * (long long)A <= N; A++){
    if(N % A != 0) continue;
    B = N / A;
    F = min(max(digits_of(A), digits_of(B)), F);
  }
  
  printf("%d", F);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
#define ll signed long long

int main() {
  ll H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (H * W + 1) / 2 << endl;
  return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int pwrmod(int a, int b )
{	int mod = M;
	int res = 1; a %= M;
	while (b)
	{
		if (b & 1) res = (1LL * res * a) % mod;
		a = (1LL * a * a) % mod;
		b >>= 1;
	}
	return res;
}
inline int mul(int a, int b) { return (1ll * a * b) % M; };
inline int add(int a, int b)
{
	if ( a + b < 0 ) return a + b + M;
	if ( a + b >= M) return a + b - M;
	return a + b;
}

void solve()
{
	int n;
	cin >> n;
	if ( n < 2 ) { cout << 0 << endl; return; }
	int total = pwrmod(10, n);
	total = add(total, -1 * pwrmod(9, n));
	total = add(total, -1 * pwrmod(9, n));

	total = add(total, pwrmod(8, n));

	cout << total << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<vector<int>> abc(3, vector<int>());
	string Sa, Sb, Sc;
	cin >> Sa >> Sb >> Sc;
	rep(i, Sa.size()) {
		if (Sa[i] == 'a') abc[0].push_back(0);
		if (Sa[i] == 'b') abc[0].push_back(1);
		if (Sa[i] == 'c') abc[0].push_back(2);
	}
	rep(i, Sb.size()) {
		if (Sb[i] == 'a') abc[1].push_back(0);
		if (Sb[i] == 'b') abc[1].push_back(1);
		if (Sb[i] == 'c') abc[1].push_back(2);
	}
	rep(i, Sc.size()) {
		if (Sc[i] == 'a') abc[2].push_back(0);
		if (Sc[i] == 'b') abc[2].push_back(1);
		if (Sc[i] == 'c') abc[2].push_back(2);
	}
	reverse(all(abc[0]));
	reverse(all(abc[1]));
	reverse(all(abc[2]));

	int a = 0;
	while(1) {
		if (abc[a].size() == 0) {
			if (a == 0) puts("A");
			if (a == 1) puts("B");
			if (a == 2) puts("C");
			return 0;
		}
		int b = abc[a][abc[a].size() - 1];
		abc[a].pop_back();
		a = b;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

int n, m;
int a[1010];
int b[1010];
int c[1010][20];
int dp[1010][(1 << 13)];

int sol (int id, int bit) {
  if (id == m) return (((1 << n) - 1 == bit) ? (0) : (INT_MAX));
  int &ret = dp[id][bit];
  if (ret != -1) return ret;
  int keys = 0;
  for (int i = 0; i < b[id]; i++) keys |= (1 << c[id][i]);
  ret = min (sol (id + 1, bit), sol (id + 1, bit | keys) + a[id]);
  return ret;
}

signed main() {
  memset (dp, -1, sizeof dp);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }
  int res = sol (0, 0);
  if (res == INT_MAX) res = -1;
  cout << res << endl;
  return 0;
}


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

int main() {
  ll n, m;
  cin >> n >> m;

  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a,b;

		while (scanner.hasNext()) {
			a = scanner.nextInt();
			b = scanner.nextInt();

			System.out.println(new String(String.valueOf(a + b)).length());
		}
	}
}

Measured memory_bytes: 26424
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;

int main(){
    string S; cin>>S;
    int Q; cin>>Q;
    vector<int> T(Q);
    vector<pair<int,char>> F(Q);
    rep(0,i,Q){
        F[i].first = 0;
        F[i].second = 0;
    }
    int token1; char token2;
    bool reversed = false;
    int Fcount = 0;
    rep(0,i,Q){
        cin >> T[i];
        if(T[i]==1){
            reversed = !reversed;
        }else if(T[i]==2){
            cin>>token1>>token2;
            if(reversed){
                if(token1 == 1){
                    token1 = 2;
                }else if(token1 == 2){
                    token1 = 1;
                }
            }
            F[Fcount].first = token1;
            F[Fcount].second =token2;
            Fcount++;
        }
    }
    string sbegin = "";
    string send = "";
    rep(0,i,Fcount+1){
        if(F[i].first==1){
            sbegin = F[i].second + sbegin;
        }else if(F[i].first == 2){
            send = send + F[i].second;
        }
    }
    S = sbegin + S + send;
    if(reversed) reverse(S.begin(),S.end());
    
    cout << S << endl;
}


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

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

ll cnt[1000];

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

    ll N,K; cin >> N >> K;
    
    ll ans = N;

    for (int i = 0;i < K;i++){
        ll d; cin >> d;
        for (int j = 0;j < d;j++){
            ll a; cin >> a;
            a--;
            if(cnt[a] == 0) ans--;
            cnt[a]++;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  char a,b,c;
  cin>>a>>b>>c;
  if(a=='7'||b=='7'||c=='7'){
    cout<<"Yes";
  }
  else
    cout<<"No";
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N);
  for (int i = 0; i < N + 1; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long cur = min(A[i], B[i]);
    ans += cur;
    B[i] -= cur;
    long long next = min(A[i + 1], B[i]);
    ans += next;
    A[i + 1] -= next;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        BigDecimal X = new BigDecimal(Math.abs(sc.nextLong()));
        BigDecimal K = new BigDecimal(sc.nextLong());
        BigDecimal D = new BigDecimal(sc.nextLong());

        BigDecimal ans = BigDecimal.ZERO;
        BigDecimal KD = K.multiply(D);
        if(X.compareTo(KD) >=0 ){
            ans = X.subtract(KD);
        }else{
            BigDecimal t = new BigDecimal(Math.min(X.longValue()/D.longValue(),K.longValue()));
            K = K.subtract(t) ;
            X = X.subtract(t.multiply(D));
            if(K.longValue()%2==0){
                ans= X;
            }else{
                ans =X.subtract(D);
            }
        }

        System.out.println(Math.abs(ans.longValue()));}}

Measured memory_bytes: 36024
#include<bits/stdc++.h>
using namespace std;
const int N=305,mod=998244353;
typedef long long ll;
int n,a[N];
ll dp[N][N*N],p[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=qpow(3,n);
    dp[0][0]=1;
    int s=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=s;j>=0;j--)
        {
            dp[i][j+a[i]]=(dp[i][j+a[i]]+dp[i-1][j])%mod;
            dp[i][j]=(dp[i][j]+dp[i-1][j]*2)%mod;
        }
        s+=a[i];
    }
    for(int i=s/2+s%2;i<=s;i++)
        ans=(ans-3*dp[n][i])%mod;
    memset(dp,0,sizeof(dp));
    s=0;dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=s;j>=0;j--)
        {
            dp[i][j+a[i]]=(dp[i][j+a[i]]+dp[i-1][j])%mod;
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        }
        s+=a[i];
    }
    if(s%2==0)
        ans=(ans+3*dp[n][s/2])%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 221952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

using namespace std;

#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;

int main() {
  int n;
  cin >> n;
  int m = INF, ans = INT_MIN;
	int tmp;
	cin >> tmp;
	m=tmp;
  rep(i, n-1) {
    cin >> tmp;
		int prevm=m;
    m = min(m, tmp);
    ans = max(ans, tmp - prevm);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <queue>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef tuple<ll,int, int, int> tup_index;
int main(int argc, char const *argv[])
{
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  REP(i, x)
  cin >> a[i];
  REP(i, y)
  cin >> b[i];
  REP(i, z)
  cin >> c[i];
  sort(ALL(a), greater<ll>());
  sort(ALL(b), greater<ll>());
  sort(ALL(c), greater<ll>());
  vector<vector<vector<bool>>> flag(x, vector<vector<bool>>(y, vector<bool>(z, false)));
  priority_queue<tup_index> q;
  q.push(make_tuple(a[0]+b[0]+c[0],0, 0, 0));
  flag[0][0][0] = true;
  for (ll i = 0; i < k; i++)
  {
    tup_index idx = q.top();
    ll val = get<0>(idx);
    int idx_a = get<1>(idx);
    int idx_b = get<2>(idx);
    int idx_c = get<3>(idx);
    cout << val <<  endl;
    q.pop();
    if (idx_a+1 < x && !flag[idx_a + 1][idx_b][idx_c])
    {
      q.push(make_tuple(a[idx_a + 1]+b[idx_b]+c[idx_c],idx_a + 1, idx_b, idx_c));
      flag[idx_a + 1][idx_b][idx_c] = true;
    }
    if (idx_b+1 < y && !flag[idx_a][idx_b + 1][idx_c])
    {
      q.push(make_tuple(a[idx_a]+b[idx_b + 1]+c[idx_c],idx_a, idx_b + 1, idx_c));
      flag[idx_a][idx_b + 1][idx_c] = true;
    }
    if (idx_c+1 < z && !flag[idx_a][idx_b][idx_c + 1] )
    {
      q.push(make_tuple(a[idx_a]+b[idx_b]+c[idx_c + 1],idx_a, idx_b, idx_c + 1));
      flag[idx_a][idx_b][idx_c + 1] = true;
    }
  }
  return 0;
}


Measured memory_bytes: 180352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out.txt","w",stdout);
#endif
    int t,x,ans = 0,n,ans1 = 0;
    scanf("%d",&t);
    n = t;
    while( t-- ){
        scanf("%d",&x);
        if( x%4 == 0 )  ans++;
        if( x%2 == 0 && x%4 != 0 )    ans1++;
    }
    bool f = ans*2+1 >= n;
    if( ans1 >= 2 ){
        f |= ans*2 >= (n-ans1);
    }
    puts(f?"Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
          string a,b,c;
          cin>>a;
          if(a=="Sunny")
          {
                    cout<<"Cloudy"<<endl;
          }
          else if(a=="Cloudy")
                    cout<<"Rainy\n";
          else
                    cout<<"Sunny\n";
return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    char a;
    cin >> a;
    if(a-'A'<26)cout << "A\n";
    else cout << "a\n";
}

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

ans = 0
tmp = 0
for v in s:
    if v in ('A', 'C', 'G', 'T'):
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
# 最後がACGT文字だった場合
ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 61816
#include<stdio.h>
long long int k;
int x;
char s[200];

int main()
{


    scanf("%s %lld",&s,&k);


    if(s[0]=='1'){
        for(x=1;s[x]!=0;x++){
            if(s[x]!='1'){
                if(x>k-1){
                    printf("1\n");
                    return 0;
                }
                printf("%c\n",s[x]);
                return 0;
            }
        }
    }
    printf("%c\n",s[0]);


    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(H: int, W: int, a: "List[List[int]]"):
    def xy(i):
        y = i // W
        x = (i % W)
        if (y % 2 == 1):
            x = (W - 1) - x
        return y ,x

    result = []
    for i in range(H * W-1):
        y, x = xy(i)
        if (a[y][x] % 2) == 1:
            y2, x2 = xy(i+1)
            a[y][x] -= 1
            a[y2][x2] += 1
            result.append("{} {} {} {}".format((y+1), (x+1), (y2+1), (x2+1)))

    return str(len(result)) + '\n' + '\n'.join(result)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ [ int(next(tokens)) for _ in range(W) ] for _ in range(H) ]  # type: "List[List[int]]"
    result = solve(H, W, a)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20140
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        double x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        int ax = x1 * 1000000 - x2 * 1000000;
        int ay = y1 * 1000000 - y2 * 1000000;
        int bx = x3 * 1000000 - x4 * 1000000;
        int by = y3 * 1000000 - y4 * 1000000;
        cout << (ax * by == ay * bx ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Fairness.Run();
        }
    }
}
namespace atcorder
{
    public class Fairness
    {
        const long unfair = 1000000000000000000;
        public Fairness()
        {
        }
        public static void Run()
        {
            long A, B, C, K;
            string s = Console.ReadLine();
            A = long.Parse(s.Split(' ')[0]);
            B = long.Parse(s.Split(' ')[1]);
            C = long.Parse(s.Split(' ')[2]);
            K = long.Parse(s.Split(' ')[3]);
            if (K % 2 == 0)
            {
                if (A - B > unfair) Console.WriteLine("Unfair");
                else Console.WriteLine(A - B);
            }
            else if (B - A > unfair) Console.WriteLine("Unfair");
            else Console.WriteLine(B - A);

        }
    }
}


Measured memory_bytes: 11092
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())

    par = [i for i in range(N)]
    rank = [1]*N
    weight = [0]*N

    def find_root(x):
        if par[x] == x:
            return x
        else:
            r = find_root(par[x])
            weight[x] += weight[par[x]]
            par[x] = r
            return par[x]

    def get_weight(x):
        find_root(x)
        return weight[x]

    def get_diff(x, y):
        return get_weight(y) - get_weight(x)

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y, w):
        w += get_weight(x)
        w -= get_weight(y)
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            x, y = y, x
            w = -w
        rank[x] += rank[y]
        par[y] = x
        weight[y] = w

    def size(x):
        # 連結成分のサイズを返す
        return rank[find_root(x)]

    for i in range(M):
        le, ri, d = (int(i) for i in input().split())
        le -= 1
        ri -= 1
        if is_same_group(le, ri):
            diff = get_diff(le, ri)
            if diff != d:
                return print("No")
        else:
            unite(le, ri, d)
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 118836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int K = Int32.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        if (S.Length <= K)
        {
            Console.WriteLine(S);
            return;
        }
        Console.WriteLine(S.Substring(0, K) + "...");
    }
}


Measured memory_bytes: 17500
N, M = map(int, input().split())

# 各行のスイッチ
switches_list = []
for i in range(M):
    line = input().split()
    switch_count = int(line[0])
    switches = [0] * N
    for j in range(switch_count):
        switches[int(line[j + 1]) - 1] = 1
    switches_list.append(switches)
# print(switches_list)

# 余り
surpluses = input().split()

count = 0
for k in range(2 ** N):
    for i in range(len(switches_list)):
        switches = switches_list[i]
        surplus = int(surpluses[i])
        on_count = 0
        for j in range(len(switches)):
            if switches[j] == 1 and ((k >> j) & 1):
                on_count += 1
        if on_count % 2 != surplus:
            break
        # 全電球分のチェックを通ったらOKとする
        if i == len(switches_list) - 1:
            count += 1
print(count)


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n >>s;
	
	rep(i, sz(s)) s[i] = (s[i] - 'A' + n)%26 + 'A';
	cout << s <<"\n";
	return 0;
}


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

int main() {
  int a,b;
  int town[4] = {0,0,0,0};
  for(int i=0;i<3;i++){
    cin >> a >> b;
    town[a-1]++;
    town[b-1]++;
  }
  bool can = (town[0]!=3)&&(town[1]!=3)&&(town[2]!=3)&&(town[3]!=3);
  cout << (can ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<class T1, class T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template<class T1, class T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);
const int S=0,T=2001,inf=0x3f3f3f3f;
const long long finf=0xc0c0c0c0c0c0c0c0ll;
struct bian
{
	int to,nxt,f,va;
}bi[3000030];
int n,head[2020],num=1,rx[1010],ry[1010],rc[1010],bx[1010],by[1010],bc[1010],from[2020];
long long dis[2020],ans;
bool bj[2020];
queue<int>q;
void add(int from,int to,int f,int va)
{
	bi[++num].nxt=head[from];
	head[from]=num;
	bi[num].to=to;
	bi[num].f=f;
	bi[num].va=va;
}
void ADD(int from,int to,int f,int va)
{
	add(from,to,f,va);
	add(to,from,0,-va);
}
bool spfa()
{
	bj[S]=1;
	q.push(S);
	memset(dis,0xc0,sizeof(dis));
	dis[S]=0;
	int x,y;
	while(!q.empty())
	{
		x=q.front();q.pop();
		bj[x]=0;
		for(int i=head[x];i;i=bi[i].nxt)
			if(bi[i].f)
			{
				y=bi[i].to;
				if(dis[x]+bi[i].va>dis[y])
				{
					dis[y]=dis[x]+bi[i].va;
					from[y]=i;
					if(!bj[y])bj[y]=1,q.push(y);
				}
			}
	}
	return dis[T]>finf;
}
 
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read("input");
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> rx[i] >> ry[i] >> rc[i]; 
		ADD(S,i,rc[i],0);
	} 
	for (int i = 1; i <= n; i++) {
		cin >> bx[i] >> by[i] >> bc[i]; 
		ADD(i+n,T,bc[i],0);
	}
	for (int i = 1; i <= n; i++) {
		ADD(i,2002,inf,rx[i]+ry[i]);
		ADD(i,2003,inf,rx[i]-ry[i]);
		ADD(i,2004,inf,-rx[i]+ry[i]);
		ADD(i,2005,inf,-rx[i]-ry[i]);
	}
	for (int i = 1; i <= n; i++) {
		ADD(2002,i+n,inf,-bx[i]-by[i]);
		ADD(2003,i+n,inf,-bx[i]+by[i]);
		ADD(2004,i+n,inf,bx[i]-by[i]);
		ADD(2005,i+n,inf,bx[i]+by[i]);
	}
	while(spfa()) {
		int x=T,flow=inf;
		while(x)flow=min(flow,bi[from[x]].f),x=bi[from[x]^1].to;
		ans+=1ll*flow*dis[T];
		x=T;
		while(x)bi[from[x]].f-=flow,bi[from[x]^1].f+=flow,x=bi[from[x]^1].to;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<unordered_map>

#define inf 0x3f3f3f3f
#define ii pair<int,int>
#define iii pair<int, ii>
#define ic pair<int, char>
#define icii pair<ic,ii>

#define pb push_back

using namespace std;
const int maxn = 55;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long i64;
 
int n, m;

char mat[maxn][maxn];
int dist[maxn][maxn];
bool vis[maxn][maxn];
using namespace std;

 
 
int oy[4] ={-1,0,1,0};
int ox[4] ={0,1,0,-1};

int bfs(){
	queue<ii> q;
	q.push({0,0});
	vis[0][0] = 1;
	while(!q.empty()){
		ii atual = q.front(); q.pop();
		int i = atual.first, j = atual.second;
	 
		for(int k = 0 ;k < 4;k++){
			
			int ni = i + oy[k], nj = j + ox[k];
			if( ni < 0 || nj < 0 || ni==n || nj ==m || vis[ni][nj] || mat[ni][nj] == '#')continue;
			vis[ni][nj] = 1;
			dist[ni][nj] = dist[i][j] + 1;
			q.push({ni,nj});
		}
	}
	return dist[n-1][m-1];
}


int main(){
	//~ freopen("in","r",stdin);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
	cin >> n >> m;
	int r = 0;
	
	for(int i = 0 ;i<n;i++){
		for(int j = 0;j < m;j++){
			cin>> mat[i][j];
			if( mat[i][j] == '#')++r;
			dist[i][j] =  vis[i][j] = 0;
		}
		dist[i][m] = vis[i][m] = 0;
	}
		 
	int ans = bfs();
	if ( ans == 0) cout<<-1<<'\n';
	else cout << ((n*m) - ans - r) - 1 <<'\n';
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int dp[100009],h[100009];
  int i,j,n;
  cin>>n;
  for(i=0;i<n;i++)
    cin>>h[i];
  dp[0]=0;
  if(n>=2)
  	dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++)
  {
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 


#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}





int main() {
   
    fastio;
    
    string s;
    cin >> s;
    bool a = true;
    rep(i, 3)
    {
        if(s[i] == s[i+1])
            a = false;
    }
    if(a)
        cout << "Good";
    else
        cout << "Bad";



    return 0; 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(m)], key = lambda x: x[1])
count = 1
broken = ab[0][1]-1
for i in range(m):
    if ab[i][0] <= broken:
        continue
    else:
        count += 1
        broken = ab[i][1]-1
print(count)

Measured memory_bytes: 29852
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct P{
	int x,id;
	inline bool operator<(P a)const{return x<a.x;}
}a[N],b[N];
int p[N];
int main(){
	int n,i,j=1;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i].x),a[i].id=i;
	for(i=1;i<=n;++i)scanf("%d",&b[i].x),b[i].id=i; 
	sort(a+1,a+n+1),sort(b+1,b+n+1);
	for(i=1;i<=n;++i)if(a[i].x>b[i].x)return puts("No"),0;
	for(i=1;i<n;++i)if(a[i+1].x<=b[i].x)return puts("Yes"),0;
	for(i=1;i<=n;++i)p[a[i].id]=i;
	for(i=p[b[1].id];i!=1;i=p[b[i].id])++j;
	puts(j==n?"No":"Yes");
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
using namespace std;
int main(){
  int N,K,X,Y;
  scanf("%d %d %d %d",&N,&K,&X,&Y);
  if(N<=K) printf("%d\n",N*X);
  else printf("%d\n",K*X+(N-K)*Y);
  return 0;
}

Measured memory_bytes: 128
i=(input())
#print(i)
l=len(i)
#print(l)
#n=[]
d=[]

for j in range(0,l-2):
  #n.append(int(i[j:j+3]))
  #print(n)
  d.append(abs(753-int(i[j:j+3])))
  #print(d)
print(min(d))

Measured memory_bytes: 2940
h,w = map(int, input().split())
a = [str(input()) for _ in range(h)]
b = []
for i in range(h):
    if a[i] != '.'*w:
        b.append(a[i])
c = []
for h in range(w):
    num = 0
    for j in b:
        if j[h] == '.':
            num += 1
    if num == len(b):
        c.append(h)
for k in b:
    word = ""
    for l in range(w):
        if l not in c:
            word += k[l]
    print(word)

Measured memory_bytes: 9200
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
vector<int> l(n);
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l.rbegin(),l.rend());
int ans=0;
for(int i=0;i<k;i++){
ans+=l[i];
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long double;
using vl = vector<long double>;
using vvl = vector<vector<long double>>;
using vvvl = vector<vector<vector<long double>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

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

long double func(vvvl &DP, ll a3, ll a2, ll a1, ll N, bool s) {
  if (DP[a3][a2][a1] != -1 && !s)
    return DP[a3][a2][a1];
  if (a3 + a2 + a1 == 0)
    return 0;
  long double add = (long double)(N) / (a3 + a2 + a1);
  if (a3 > 0)
    add += func(DP, a3 - 1, a2 + 1, a1, N, false) *
           ((long double)a3 / (a3 + a2 + a1));
  if (a2 > 0)
    add += func(DP, a3, a2 - 1, a1 + 1, N, false) *
           ((long double)a2 / (a3 + a2 + a1));
  if (a1 > 0)
    add +=
        func(DP, a3, a2, a1 - 1, N, false) * ((long double)a1 / (a3 + a2 + a1));
  DP[a3][a2][a1] = add;
  return add;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(3, 0);
  REP(i, N) {
    ll a;
    cin >> a;
    A[a - 1]++;
  }
  vvvl DP = VVVL(N + 1, N + 1, N + 1, -1);
  DP[A[2]][A[1]][A[0]] = 0;
  cout << SP(20) << func(DP, A[2], A[1], A[0], N, true) << endl;

  return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int[] waseda = new int[10];
		int[] keio = new int[10];
		
		for(int i = 0; i < 10; i++){
			waseda[i] = Integer.parseInt(br.readLine());
		}
		
		for(int i = 0; i < 10; i++){
			keio[i] = Integer.parseInt(br.readLine());
		}
		
		Arrays.sort(waseda);
		Arrays.sort(keio);
		
		int scorew = waseda[9] + waseda[8] + waseda[7];
		int scorek = keio[9] + keio[8] + keio[7];
		
		System.out.println(scorew + " " + scorek);
	}

}

Measured memory_bytes: 24120
#include <bits/stdc++.h>
using namespace std;
bool isVowel(char c){
	return (c=='a' or c=='e' or c=='i' or c=='o' or c=='u');
}
int main() {
	// your code goes here
	int a,b;
	string op;
	cin>>a>>op>>b;
	printf("%d\n", op=="+" ? a+b : a-b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#define N_MAX 100001
#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef pair<int, int> iP;

int ts[N_MAX], sum[N_MAX];

int main(){
  
  int N, R, L, d, t, x;
  
  cin >> N >> R >> L;
  priority_queue<iP, vector<iP> > que;
  
  ts[0] = sum[0] = -INF;
  que.push(iP(0, -1));
  int pid = 1, pt = 0;
  for(int i = 0; i < R; i++){
    cin >> d >> t >> x;
    sum[d] += x;
    que.push(iP(sum[d], -d));
    while(1){
      iP p = que.top();
      if(p.fr == sum[-p.second]){
	ts[pid] += t - pt;
	pt = t;
	pid = -p.sc;
	break;
      }
      que.pop();
    }
  }
  ts[pid] += L - pt;
  
  cout << max_element(ts+1, ts+N+1) - ts << endl;

}

Measured memory_bytes: 9800
//beet

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define MAX 114514
vector<P> G[MAX*5];
map<int,int> M[MAX];
int dist[MAX*5];
signed main(){
  int n,m;
  cin>>n>>m;
  int cnt=n;
  for(int i=0;i<m;i++){
    int p,q,c;
    cin>>p>>q>>c;
    p--;q--;
    auto add_edge = [&](int x){
      if(!M[x].count(c)){
	M[x][c]=cnt++;
	G[M[x][c]].push_back(P(x,0));
	G[x].push_back(P(M[x][c],1));
      }
    };
    add_edge(p);
    add_edge(q);
    G[M[p][c]].push_back(P(M[q][c],0));
    G[M[q][c]].push_back(P(M[p][c],0));
  }
  memset(dist,-1,sizeof(dist));
  priority_queue<P,vector<P>,greater<P> > q;
  dist[0]=0;
  q.push(P(dist[0],0));
  while(!q.empty()){
    P p=q.top();q.pop();
    int d=p.first,v=p.second;
    if(dist[v]<d) continue;
    for(P e:G[v]){
      int u=e.first,c=e.second;
      if(dist[u]<0||dist[u]>d+c){
	dist[u]=d+c;
	q.push(P(dist[u],u));
      }
    }
  }
  cout<<dist[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 82544
#include <stdio.h>

int main (void)
{
    long X,Y;
    scanf("%ld %ld",&X,&Y);
    if(X>=Y&&X%Y==0)
    {
        puts("-1");
        return 0;
    }
    for(long i=1;i<Y;i++)
    {
        if(X*i%Y!=0)
        {
            printf("%ld",X*i);
            break;
        }
    }
    return 0;
}

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

up_lift = [0]*N
down_lift = [0]*N
for i in range(N):
    if i + A[i] < N:
        up_lift[i + A[i]] += 1
    if i - A[i] >= 0:
        down_lift[i - A[i]] += 1

print(sum([up_lift[i] * down_lift[i] for i in range(N)]))

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

int main() {
    int N;
    cin >> N;
    long long a[100],sum[201];
    long long cost=1000000000;
    for(int i=0;i<N;i++) cin >> a[i];

    for(int i=-100;i<101;i++){
        sum[i] = 0;
        for(int j=0;j<N;j++){
            sum[i] += (i-a[j])*(i-a[j]);
        }
        cost = min(cost, sum[i]);
    }

    cout << cost << endl;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    int elaps = 0, c;
    queue< pair<string, int> > Q;
    pair<string, int> p("", 0);
    for (int i = 0; i < n; i++) {
        string k;
        int v;
        cin >> k >> v;
        p = make_pair(k, v);
        Q.push(p); 
    }
    while (!Q.empty()) {
        p = Q.front();
        Q.pop();
        c = min(q, p.second);
        int calv = p.second - c;
        p = make_pair(p.first, calv);
        elaps += c;
        if (calv > 0) Q.push(p);
        else {
            cout << p.first << " " << elaps << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 6232
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    int ans=0;
    for(int i=0;i<N;i++){
        ans += L + i;
    }
    if(L<0){
        if(N<=-L){
            ans -= L + (N-1);
        }
    }
    else{
        ans -= L;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256