akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int N, A, B, C;
vector<int> l;

int dfs(int i, int a, int b, int c, int n) {
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 1e9;
    } else {
      return abs(A-a) + abs(B-b) + abs(C-c) + (n-3) * 10;
    }
  }

  int MP = 1e9;
  MP = min(MP, dfs(i + 1, a + l[i], b, c, n + 1));
  MP = min(MP, dfs(i + 1, a, b + l[i], c, n + 1));
  MP = min(MP, dfs(i + 1, a, b, c + l[i], n + 1));
  MP = min(MP, dfs(i + 1, a, b, c, n));
  return MP;
}

int main() {
  cin >> N >> A >> B >> C;
  l.resize(N); cin >> l;

  cout << dfs(0, 0, 0, 0, 0) << endl;
}


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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] params = br.readLine().split(" ");
      double a = Double.parseDouble(params[0]);
      double b = Double.parseDouble(params[1]);
      double C = Double.parseDouble(params[2]);

      double rC= Math.toRadians(C);
      double l = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(rC)) + a + b;
      double h = b * Math.sin(rC);
      double s = a * h / 2;

      System.out.printf("%.8f\n%.8f\n%.8f\n", s,l,h);
    }
  }
}


Measured memory_bytes: 24836
#include    <iostream>
#include    <cmath>

using namespace std;

int main() {
    int n;
    double xa, ya, ra, xb, yb, rb, d;

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> xa >> ya >> ra >> xb >> yb >> rb;

        d =sqrt(pow(xa - xb, 2.0) + pow(ya - yb, 2.0));
        if(d + rb < ra)          { cout << "2"  << endl; }
        else if(d + ra < rb) { cout << "-2" << endl; }
        else if(d <= ra + rb)    { cout << "1"  << endl; }
        else                    { cout << "0"  << endl; }
    }
    return 0;
}


Measured memory_bytes: 3132
/**
 * Sort I - Bubble Sort
 */

#include <iostream>

using namespace std;

int main() {
    int N, A[100], count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = N - 1; i >= 1; i--) {
        for (int j = 0; j < i; j++) {
            if (A[j] > A[j + 1]) {
                A[j] += A[j + 1];
                A[j + 1] = A[j] - A[j + 1];
                A[j] = A[j] - A[j + 1];
                count++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i < N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3076
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int nums[105];

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int num;
    scanf("%d", &num);
    for (int i = 0; i < num; i++)
    {
        scanf("%d", &nums[i]);
    }
    
    if(1 == num) printf("%d\n", nums[0]);
    else {
        printf("%d", nums[0]);
        for (size_t i = 1; i < num; i++)
        {
            printf(" %d", nums[i]);
        }
        printf("\n");
        
        for(int i = 1; i < num; ++i) {
            int tmp = nums[i];
            int j = i - 1;
            while(j >= 0 && tmp < nums[j]) {
                nums[j + 1] = nums[j];
                j--;
            }
            nums[j + 1] = tmp;
            printf("%d", nums[0]);
            for (size_t i = 1; i < num; i++)
            {
                printf(" %d", nums[i]);
            }
            printf("\n");
        }
    }
    

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2132
import java.util.*;

public class Main {
    public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int str1 = Integer.parseInt((String)scan.nextLine());
      String tmp = scan.nextLine();
      
     String[] hani = tmp.split(" ",0);
      
      String result = "NG";
      for(int i=Integer.parseInt(hani[0]);i<=Integer.parseInt(hani[1]);i++){
        if(i%str1==0){
           result="OK";
          break;
        }
      }
      
      System.out.println(result);
      scan.close();
    }
}

Measured memory_bytes: 35844
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    /*
    int a[3], b[3];
    for (int i = 0; i < 3; i++) {
        std::cin >> a[i] >> b[i];
    }

    int A, B, C, D;
    for (int i = 0; i < 3; i++) {
        if (a[i] == 1) {
            A++;
        }
        if (a[i] == 2) {
            B++;
        }
        if (a[i] == 3) {
            C++;
        }
        if (a[i] == 4) {
            D++;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (b[i] == 1) {
            A++;
        }
        if (b[i] == 2) {
            B++;
        }
        if (b[i] == 3) {
            C++;
        }
        if (b[i] == 4) {
            D++;
        }
    }
    */

    int a[6];
    for (int i = 0; i < 6; i++) {
        std::cin >> a[i];
    }

    int A = 0;
    int B = 0;
    int C = 0;
    int D = 0;

    for (int i = 0; i < 6; i++) {
        if (a[i] == 1) {
            A++;
        }
        if (a[i] == 2) {
            B++;
        }
        if (a[i] == 3) {
            C++;
        }
        if (a[i] == 4) {
            D++;
        }
    }

    if (A == 2 && B == 2 && C == 1 && D == 1) {
        std::cout << "YES" << std::endl;
    } else if (A == 2 && B == 1 && C == 2 && D == 1) {
        std::cout << "YES" << std::endl;
    } else if (A == 2 && B == 1 && C == 1 && D == 2) {
        std::cout << "YES" << std::endl;
    } else if (A == 1 && B == 2 && C == 2 && D == 1) {
        std::cout << "YES" << std::endl;
    } else if (A == 1 && B == 2 && C == 1 && D == 2) {
        std::cout << "YES" << std::endl;
    } else if (A == 1 && B == 1 && C == 2 && D == 2) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}


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

int main(){
    int x;
    vector<int> xs;
    for(int i=0; i<3; i++){
        cin >> x;
        xs.push_back(x);
    }

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

    cout << xs[0] * xs[1] / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define f(i,a,b) for(int i=(a);i<(b);++i)
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
const int maxn= 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

ll fun(ll n)
{
    ll ans=1;
    for(ll i=2;i<=n;i++)
    {
        ans=ans*i%mod;
    }
    return ans;
}

int main()
{
    ll n,m;
    while(cin>>n>>m)
    {
        if(n>m+1||m>n+1)
        {
            puts("0");
            continue;
        }
        ll a=fun(m);
        ll b=fun(n);
        ll ans=(a*b)%mod;
        if(n==m)
            ans=ans*2%mod;
        printf("%I64d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i, N){
    cin >> a[i];
  }
  sort(a, a+N);
  ll ans = 0;
  rep(i, N){
    for(int j=i+1; j<N; j++){
      int wa = a[i] + a[j]; 
      int sa = abs(a[i] - a[j]);
      int high = lower_bound(a, a+N, wa) - a;
      int low = upper_bound(a, a+N, sa) - a;
      ans += (ll) (high - low - 1);
      if(a[i] > a[j]/2) ans--;
    }
  }
  cout << ans/3 << endl;
      
    
}

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

using namespace std;

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

vector<int> G[4];
bool used[4];

bool dfs(int u, int depth){
	if (depth == 3){
		return true;
	} // end if

	used[u] |= true;
	bool res = false;
	rep (i, (int)G[u].size()){
		int v = G[u][i];
		if (!used[v]){
			res |= dfs(v, depth + 1);
		} // end if
	} // edn rep

	return res;
}

int main()
{
	rep (i, 4) G[i].clear();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	rep (i, 3){
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	} // end rep

	memset(used, false, sizeof(used));
	bool res = dfs(0, 0);

	cout << (res ? "YES" : "NO") << endl;

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d ;
  
  if(a + b > c + d) {
    cout << "Left" <<endl;
  }
  
  if(a + b == c + d) {
    cout << "Balanced" <<endl;
  }
  
  if(a + b < c + d) {
    cout << "Right" <<endl;
  }
 }

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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    vector<int> num;
    int x,n;
    cin>>x>>n;
    vector<int> a(n);
    for(auto &l : a) cin>>l;
    for(int i=0;i<=101;++i){
        if(find(a.begin(),a.end(),i)==a.end()){
            num.push_back(i);
        }
    }
    int mx = INT_MAX;
    int ans = INT_MAX;
    for(auto l : num) {
        //cout<<l<<" ";
        if(mx > abs(l-x)){
            mx = abs(l-x);
            if(ans > l) ans = l;
        }
    }
    for(auto l : num) if(mx==abs(l-x)){cout<<l;
            break;}
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int h, w; cin >> h >> w;
    int cnt = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            char c; cin >> c;
            if(c == '#') cnt++;
        }
    }

    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    printf("%d %d %.5f\n", a / b, a % b, (double) a / b);
}

Measured memory_bytes: 1176
n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
x_sum = sum(x)
ans = 0
if x_max >= a:
    dp = [[0 for j in range(2 * x_sum + 1)] for i in range(2)]
    dp[0][x_sum] = 1
    for i in range(1, n + 1):
        idx = i % 2
        y = x[i - 1] - a
        for j in range(2 * x_sum + 1):
            if 0 <= j - y <= 2 * x_sum:
                dp[idx][j] = dp[1 - idx][j] + dp[1 - idx][j - y]
            else:
                dp[idx][j] = dp[1 - idx][j]
    ans = dp[n % 2][x_sum] - 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>

int main(void){
    long long n, a, b;
    std::cin >> n >> a >> b;
    long long ans;
    long long tmp = n / (a + b);
    ans = tmp * a;
    long long tmp2 = n % (a + b);
    if(tmp2 >= a){
	std::cout << ans + a << std::endl;
    }else{
	std::cout << ans + tmp2 << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }

        long ans = 1;
        long mod = 1000000007;
        int[] b = new int[3];
        for (int i = 0 ; i < n ; i++) {
            int c = 0;
            for (int j = 0 ; j < 3 ; j++) {
                if (a[i] == b[j]) {
                    c++;
                    if (c == 1) b[j]++;
                }

            }
            ans *= (long) c;
            ans %= mod;

        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 49596
n,l=map(int,input().split())
aji=list(range(l,l+n))
ans=0
sa=abs(sum(aji))

for i in range(n):
  pie=sum(aji)-aji[i]
  if sa>abs(sum(aji)-pie):
    sa=abs(sum(aji)-pie)
    ans=pie

print(ans)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define n_ones(x) __builtin_popcountll(x)
#define n_trailzero(x) __builtin_ctzll(x)
#define n_leadingzero(x) __builtin_clz(x)

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;
typedef map<ll,ll>::iterator mit;
typedef set<ll>::iterator sit;
typedef vector<ll>::iterator vit;

ll mod = 1e9 + 7;
ll dp[3005][3005];
string st, s, t;

void ans(ll m, ll n)
{
	if(m == 0 || n == 0)
		return;
	if(s[m-1] == t[n-1])
	{
		st.pb(s[m-1]);
		ans(m-1, n-1);
		return;
	}
	if(dp[m-1][n] > dp[m][n-1])
		ans(m-1, n);
	else
		ans(m, n-1);
}

void solve()
{
	cin>>s;
	cin>>t;
	ll m = s.size(), n = t.size();
	rep(i, m+1)
	{
		rep(j, n+1)
		{
			if(i == 0 || j == 0)
				dp[i][j] = 0;
			else if(s[i-1] == t[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout<<dp[m][n]<<endl;
	ans(m, n);
	reverse(st.begin(), st.end());
	cout<<st<<endl;
	return;
}


int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
	{
		solve();
	}
	return 0;	
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int f[5010][5010],n,m;
char s[5010];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>s;m=strlen(s);
	f[0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=i;++j){
			f[i][j]=2*f[i-1][j+1]%mod;
			if(j)f[i][j]=(f[i][j]+f[i-1][j-1])%mod;
			else f[i][j]=(f[i][j]+f[i-1][j])%mod;
		}
	}
	cout<<f[n][m]<<'\n';
	return 0;
}


Measured memory_bytes: 96512
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var li=new List<int>[s[1]+1];
		for(int i = 1;i<=s[1];i++) {
			li[i]=new List<int>();
			li[i].Add(i-1);
		}
		for(int i = 0;i<s[2];i++) {
			var e=sc.Ia;
			if(e[0]<e[1]){continue;}
			li[e[1]].Add(e[0]);
		}
		int ans=int.MaxValue;
		int c=2;
		for(int i = 1;i<=s[1];i++) {
			li[i].Add(s[0]+1);
			li[i].Sort();
			for(int j = 1;j<li[i].Count;j++) {
				if(li[i][j]>li[i][j-1]+1&&li[i][j]>=c){
					ans=Min(ans,li[i][j]-1);
					c=Max(li[i][j-1]+3,c+1);
					break;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 41380
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

ll N;
ll a[200010];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	rep(i, N)cin >> a[i];
	ll right = 0;
	ll ans = 0;
	ll nowxor = 0;
	ll nowsum = 0;
	for (ll left = 0; left < N; left++) {
		while (right < N && (nowxor ^ a[right]) == (nowsum + a[right])) {
			nowxor ^= a[right];
			nowsum += a[right];
			right++;
		}
		ans += right - left;
		if (left == right)right++;
		else {
			nowxor ^= a[left];
			nowsum -= a[left];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		//入力
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int l=Integer.parseInt(st.nextToken());
        long[][] Aary=new long[n][m];
        long[][] Bary=new long[m][l];
        for(int j=0;j<n;j++){
            StringTokenizer sa=new StringTokenizer(br.readLine());
            for(int i=0;i<m;i++){
                Aary[j][i]=Long.parseLong(sa.nextToken());
            }
        }
        for(int j=0;j<m;j++){
            StringTokenizer sb=new StringTokenizer(br.readLine());
            for(int i=0;i<l;i++){
                Bary[j][i]=Long.parseLong(sb.nextToken());
            }
        }

        //配列の作成と加工
        long[][] Cary = new long[n][l];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                long sum = 0;
                for (int k = 0; k < m; k++) {
                    sum += Aary[i][k] * Bary[k][j];
                }
                Cary[i][j] = sum;
            }
        }

        //出力
        for(int j=0;j<n;j++){
            for(int i=0;i<l;i++){
                System.out.print(Cary[j][i]);
                if(i==l-1) {
                	continue;
                }
                System.out.print(" ");
            }
            System.out.println();
        }
	}

}



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

int main(){
    int n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i]=INT_MAX;
        for(int j=1; j<=k; j++){
            if((i-j)>=0){
               dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
            }
        }

    }
    cout<<dp[n-1];
}


Measured memory_bytes: 5160
N = int(input())
Ss = []
for i in range(N):
	Ss.append(input())
	
C0, C1, C2, C3 = 0, 0, 0, 0
for S in Ss:
	if S == 'AC':
		C0 += 1
	elif S == 'WA':
		C1 += 1
	elif S == 'TLE':
		C2 += 1
	else:
		C3 += 1
print("AC x {}".format(C0))
print("WA x {}".format(C1))
print("TLE x {}".format(C2))
print("RE x {}".format(C3))

Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
long long dp[110][100010];
long long weight[110], value[110];

int main()
{
    int N, W; cin >> N >> W;
    rep(i, N) cin >> weight[i] >> value[i];

    rep(i, N)
    {
        rep(j, W + 1)
        {
            if (j - weight[i] >= 0)
                chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);

            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;
}


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

int main(){
	int n, p;
	cin >> n;
	for(int i = 1, sum = 0; i <= n; i++){
		sum += i;
		if(sum >= n){
			p = i;
			break;
		}
	}
	for(int i = p; i > 0; i--){
		if(n == 0) break;
		if(n - i >= 0){
			n -= i;
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    vector<ll> v={0};
    REP(i,n){
        ll a;cin>>a;
        v.push_back(a);
    }
    v.push_back(0);
    ll sum=0;
    REP(i,n+2){
        sum+=abs(v[i]-v[i+1]);
    }
    FOR(i,1,n+1){
        ll ans;
        ans=sum+abs(v[i-1]-v[i+1])-abs(v[i-1]-v[i])-abs(v[i]-v[i+1]);
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int n;
int l[8];
int A, B, C;

int dfs(int k, int a, int b, int c)
{
    if (k == n) {
        if (a == 0 || b == 0 || c == 0) return 1e9;
        return abs(a - A) + abs( b - B) + abs(c - C);
    }

    int ans = 1e9;
    ans = min(ans, dfs(k + 1, a + l[k], b, c) + (a > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b + l[k], c) + (b > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b, c + l[k]) + (c > 0 ? 10 : 0));
    ans = min(ans, dfs(k + 1, a, b, c));
    return ans;
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        cin >> n >> A >> B  >> C;
        for (int i = 0; i < n; i++) cin >> l[i];
        int upper = 1;
        for (int i = 0; i < n; i++) {
            upper *= 4;
        }
        int ans = 1e9;
        for (int i = 0; i < upper; i++) {
            vector<int> sum(3, 0);
            vector<int> cnt(3, 0);
            int used = 0;
            int cpy = i;
            for (int j = 0; j < n; j++) {
                int tmp = cpy % 4;
                cpy /= 4;
                if (tmp == 3)continue;
                cnt[tmp]++;
                sum[tmp] += l[j];
            }
            bool flag = true;
            for (int j = 0; j < 3; j++) {
                if (!cnt[j]) flag = false;
                used += 10 * (cnt[j] - 1);
            }
            for (int j = 0; j  < 3; j++) {
                int p = (j == 0 ? A : (j == 1 ? B : C));
                used += abs(p - sum[j]);
            }
            if (flag) ans = min(ans, used);
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
text=input()
N=text

temp4=[4*i for i in range(25)]
temp7=[7*i for i in range(14)]

temp=list()
flg=False
for i in temp4:
    for j in temp7:
        temp.append(i+j)
        if int(N)==i+j:
            flg=True
            print("Yes")
            exit()

if flg:
    pass
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main() {
     
    string s;
    cin >> s;
     
    int ans = 0;
    int n = s.size();
    if(n % 2 == 0){
        rep(i, n/2){
            if(s[i] == 'i' && s[n-1-i] == 'i') continue;
            if(s[i] == 'w' && s[n-1-i] == 'w') continue;
            if(s[i] == '(' && s[n-1-i] == ')') continue;
            if(s[i] == ')' && s[n-1-i] == '(') continue;
             
            ans++;
        }
    }
    else{
        rep(i, (n - 1)/2){
            if(s[i] == 'i' && s[n-1-i] == 'i') continue;
            if(s[i] == 'w' && s[n-1-i] == 'w') continue;
            if(s[i] == '(' && s[n-1-i] == ')') continue;
            if(s[i] == ')' && s[n-1-i] == '(') continue;
             
            ans++;
        }
        if(s[(n-1)/2] != 'i' && s[(n-1)/2] != 'w') ans++;
    }
     
    cout << ans << endl;
     
 
    return 0;
}

Measured memory_bytes: 3140
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a<=c&&b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
   
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
          return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
  
    public static bool bingo(bool[,] abool)
    {
        for (int i = 0; i < 3; i++)
        {
            var count = 0;
            for (int j = 0; j < 3; j++)
            {
                if (abool[i, j])
                    count++;
            }
            if (count == 3)
                return true;
        }
        for (int i = 0; i < 3; i++)
        {
            var count = 0;
            for (int j = 0; j < 3; j++)
            {
                if (abool[j, i])
                    count++;
            }
            if (count == 3)
                return true;
        }
        var count0 = 0;
        for (int i = 0; i < 3; i++)
        {        
            if (abool[i, i])
                count0++;
        }
        if (count0 ==3)
            return true;
        var count1 = 0;
        for (int i = 0; i < 3; i++)
        {
            if (abool[i, 2-i])
                count1++;
        }
        if (count1 == 3)
            return true;

        return false;

    }
    public static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var a = new long[3, 3];
        var abool = new bool[3, 3];
        for(int i = 0; i < 3; i++)
        {
            var input = Reads();
            for (int j = 0; j < 3; j++)
            {
                a[i, j] = input[j];
                abool[i, j] = false;
            }
        }
       
        var n = Read();
        var b = new long[n];
        for (int j = 0; j < n; j++)
        {
            b[j] = Read();
        }
        for (int k = 0; k < n; k++)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (a[i, j] == b[k])
                        abool[i, j] = true;
                }
            }
        }
        if (bingo(abool))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");

          
        Console.Out.Flush();

    }
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

double ans;
int n, m;
vector<double> x, y;
void rec(int bits, int a, double sum) {
    if (bits == (1 << n) - 1) {
    //    cout << sum << endl;
        ans += sum;
        return;
    }

    double res = 0;
    int cnt = 0;
    rep(i, n) {
        if ((bits & (1 << i)) == 0) {
            double xx = abs(x[a] - x[i]);
            double yy = abs(y[a] - y[i]);
            double d = sqrt(xx * xx + yy * yy);
            rec(bits + (1 << i), i, sum + d);
            cnt++;
        }
    }
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    m = 1;
    rep(i, n) {
        m *= i + 1;
    }

    ans = 0;

    rep(i, n) {
        double _x, _y;
        cin >> _x >> _y;
        x.push_back(_x);
        y.push_back(_y);
    }

    rep(i, n) {
        rec((1 << i), i,0);
    }

    cout << ans / double(m) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
N=int(input())
b=list(map(int,input().split()))
flag=0
op=deque()
#1→12→122→1232→11232→121232→1221232→11221232→111221232
#print(b)
while len(b)>0:
    for i in range(len(b)-1,-1,-1):
        if b[i]==i+1:
            #print(b[i])
            op.appendleft(b.pop(i))
            flag=1
            break
    if flag==0:
        break
    flag=0
    #print(op,b)
#print(op)
if len(b)==0:
    for i in range(N):
        print(op.popleft())
else:
    print("-1")


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

int main(){
    int A, B;
    cin >> A >> B;
    int ans=(B-1+A-1-1)/(A-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
int main(void)
{
    ll a, c;
    double b;
    scanf("%lld %lf" ,&a,&b);
    c = round(100*b);
    printf("%lld" ,a*c/100);
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
const long long INF=1e9+5;
const string alp="abcdefghijklmnopqrstuvwxyg"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYG";
typedef long long ll;

int main() {
  string s;
  cin>>s;
  vector<char> vec;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      vec.push_back('0');
    }
    else if(s[i]=='1'){
      vec.push_back('1');
    }
    else{
      if(!vec.empty()){
        vec.pop_back();
      }
    }
  }
  string ans;
  for(int i=0;i<vec.size();i++){
    ans+=vec.at(i);
  }
  cout<<ans<<endl;
      
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

void pri(vector<string> a) {
  rep(i, a.size()) {
    cout << a[i] << endl;
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> b(h);
  rep(i, h) cin >> b[i];

  bitset<110> okx;
  bitset<110> oky;

  rep(i, h) {
    rep(j, w) {
      if(b[i][j] == '#') {
        okx.set(i, true);
        oky.set(j, true);
      }
    }
  }

  rep(i, h) {
    if(okx.test(i)) {
      rep(j, w) {
        if(oky.test(j)) {
          cout << b[i][j] << flush;
        }
      }
      cout << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int MAX=10000;
constexpr int NIL=-1;

struct Node{int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
   if(u==NIL) return;
   D[u]=d;
   setDepth(T[u].left, d+1);
   setDepth(T[u].right, d+1);
}

int setHeight(int u){
   int h1=0, h2=0;
   if(T[u].left!=NIL)
      h1=setHeight(T[u].left)+1;
   if(T[u].right!=NIL)
      h2=setHeight(T[u].right)+1;
   return H[u]=(h1>h2 ? h1:h2);
};

int getSibling(int u){
   if(T[u].parent==NIL) return NIL;
   if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
      return T[T[u].parent].left;
   if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
      return T[T[u].parent].right;
   return NIL;
}

void print(int u){
   cout << "node " << u << ": ";
   cout << "parent = " << T[u].parent << ", ";
   cout << "sibling = " << getSibling(u) << ", ";
   int deg=0;
   if(T[u].left != NIL) deg++;
   if(T[u].right != NIL) deg++;
   cout << "degree = " << deg << ", ";
   cout << "depth = " << D[u] << ", ";
   cout << "height = " << H[u] << ", ";

   if(T[u].parent == NIL){
      cout << "root" << endl;
   }
   else if(T[u].left == NIL && T[u].right == NIL){
      cout << "leaf" << endl;
   }
   else{
      cout << "internal node" << endl;
   }
}

int main(){
   int v, l, r, root=0;
   cin >> n;

   for(int i=0; i<n; i++) T[i].parent=NIL;
   for(int i=0; i<n; i++){
      cin >> v >> l >> r;
      T[v].left=l;
      T[v].right=r;
      if(l != NIL) T[l].parent=v;
      if(r != NIL) T[r].parent=v;
   }
   for(int i=0; i<n; i++){
      if(T[i].parent == NIL) root=i;
   }
   setDepth(root, 0);
   setHeight(root);

   for(int i=0; i<n; i++) print(i);

   return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
vector<pair<int, int>> dat;

//inputします
void input() {
    cin >> n;
    dat.resize(n);
    ff(i, 0, n) {
        int a, b;
        cin >> a >> b;
        dat[i] = { a + b,a - b };
    }
    srt(dat);
}

//ライブラリ置き場

//main
int main() {
    input();
    int now = 1;
    int last = dat[0].first;
    int ans = 1;
    while (now < n) {
        if(dat[now].second < last) {
            //cout << now << "は除かれます。" << endl;
            now++;
            continue;
        }
        //cout << now << "は除かれません。" << endl;
        last = dat[now].first;
        ans++;
        now++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
      int N;
      cin>>N;
      for(int n=1;n<=N;n++){
			if(n%3==0){
				cout<<" "<<n;
			}else{
				int a=n;
				while(a!=0){
					if(a%10==3){
						cout<<" "<<n;
						break;
					}else{
						a=a/10;
					}
				}
			}
	  }
	  cout<<endl;
}



Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

// 約数の列挙O(sqrt(n))
vector<ll> divisor (ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) res.push_back(n / i);
        }
    }
    return res;
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v = divisor(n);

    ll ans = LLONG_MAX;
    for (auto i : v)
    {
        ll temp = n / i;
        ans = min(ans, temp + i - 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define dalao 1000000007
#define N 200010
typedef long long ll;
using namespace std;
struct wxh{
	int x,v;
	bool operator <(const wxh& b)const{return v<b.v;}
}a[N];
struct yjq{
	int l,r;
	bool operator <(const yjq& b)const{return l<b.l||(l==b.l&&r<b.r);}
}b[N];
int n,x[N],t[N],sum[N<<2],tag[N<<2],tag2[N<<2];
inline void upd(int& a,int b){a+=b;if(a>=dalao)a-=dalao;}
inline int add(int a,int b){return a+b>=dalao?a+b-dalao:a+b;}
inline void down(int x,int l,int r){
	if(tag2[x]^1){
		if(l^r){
			tag2[x<<1]=1ll*tag2[x<<1]*tag2[x]%dalao,tag2[x<<1|1]=1ll*tag2[x<<1|1]*tag2[x]%dalao;
			tag[x<<1]=1ll*tag[x<<1]*tag2[x]%dalao,tag[x<<1|1]=1ll*tag[x<<1|1]*tag2[x]%dalao;
			sum[x<<1]=1ll*sum[x<<1]*tag2[x]%dalao,sum[x<<1|1]=1ll*sum[x<<1|1]*tag2[x]%dalao;
		}
		tag2[x]=1;
	}
	if(tag[x]){
		if(l^r){
			int mid=l+r>>1;
			upd(tag[x<<1],tag[x]),upd(tag[x<<1|1],tag[x]);
			upd(sum[x<<1],1ll*(mid-l+1)*tag[x]%dalao),upd(sum[x<<1|1],1ll*(r-mid)*tag[x]%dalao);
		}
		tag[x]=0;
	}
}
inline void modify(int x,int l,int r,int L,int R,int v){
	down(x,L,R);
	if(l==L&&r==R){upd(sum[x],1ll*(r-l+1)*v%dalao),upd(tag[x],v);return;}
	int mid=L+R>>1;
	if(r<=mid)modify(x<<1,l,r,L,mid,v);
	else if(l>mid)modify(x<<1|1,l,r,mid+1,R,v);
	else modify(x<<1,l,mid,L,mid,v),modify(x<<1|1,mid+1,r,mid+1,R,v);
	sum[x]=add(sum[x<<1],sum[x<<1|1]);
}
inline void modify2(int x,int l,int r,int L,int R,int v){
	down(x,L,R);
	if(l==L&&r==R){sum[x]=1ll*sum[x]*v%dalao,tag2[x]=1ll*tag2[x]*v%dalao,tag[x]=1ll*tag[x]*v%dalao;return;}
	int mid=L+R>>1;
	if(r<=mid)modify2(x<<1,l,r,L,mid,v);
	else if(l>mid)modify2(x<<1|1,l,r,mid+1,R,v);
	else modify2(x<<1,l,mid,L,mid,v),modify2(x<<1|1,mid+1,r,mid+1,R,v);
	sum[x]=add(sum[x<<1],sum[x<<1|1]);
}
inline int query(int x,int l,int r,int L,int R){
	down(x,L,R);
	if(l==L&&r==R)return sum[x];
	int mid=L+R>>1;
	if(r<=mid)return query(x<<1,l,r,L,mid);
	else if(l>mid)return query(x<<1|1,l,r,mid+1,R);
	return add(query(x<<1,l,mid,L,mid),query(x<<1|1,mid+1,r,mid+1,R));
}
namespace init_b{
	int mi[N],mx[N],smi[N],smx[N];
	inline void main(){
		mset(mi,inf);
		for(int i=1;i<=n;i++)mi[a[i].x]=min(mi[a[i].x],i),mx[a[i].x]=max(mx[a[i].x],i);
		for(int i=1;i<=n;i++)smx[i]=max(smx[i-1],mx[i]);
		smi[n+1]=inf;
		for(int i=n;i;i--)smi[i]=min(smi[i+1],mi[i]);
		for(int i=1;i<=n;i++)b[i].l=smi[a[i].x],b[i].r=smx[a[i].x];
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].v),x[i]=a[i].x;
	sort(x+1,x+1+n),sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)a[i].x=lower_bound(x+1,x+1+n,a[i].x)-x;
	init_b::main();
	sort(b+1,b+1+n);
	modify(1,0,0,0,n,1);
	for(int i=1;i<=n;i++){
		int c=query(1,b[i].l-1,b[i].r,0,n);
		modify(1,b[i].r,b[i].r,0,n,c);
		if(b[i].r<n)modify2(1,b[i].r+1,n,0,n,2);
	}
	printf("%d",query(1,n,n,0,n));
	return 0;
}

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

int main(){
  int n,a[100][100],b[100]={},c[100]={};
  c[0]=1;
  cin>>n;
  for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)cin>>a[i][j];

  int k=1,min1,ans=0;
  while(1){
   int min=10000;
   for(int i=0;i<k;i++)
    for(int j=0;j<n;j++)
     if(a[b[i]][j]<min && a[b[i]][j]!=-1 &&c[j]!=1){
      min=a[b[i]][j];
      min1=j;
    }
   if(k==n)break;
   b[k]=min1;
   c[min1]=1;
   ans+=min;
   k++;
  }

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

Measured memory_bytes: 1196
n, m = map(int, input().split())
t = [-1] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if t[s] != -1 and t[s] != c:
        print(-1)
        exit()
    t[s] = c

if n != 1:
    if t[0] == 0:
        print(-1)
        exit()
    if t[0] == -1:
        t[0] = 1
    for i in range(n):
        if t[i] == -1:
            t[i] = 0
else:
    if t[0] == -1:
        t[0] = 0
    
print(''.join(map(str, t)))

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,k,a,b,ans,p,q;
int main(){
	cin>>n>>k;
	if(k==0){
		cout<<n*n;
		return 0;
	}
	if(n<=k){
		cout<<0;
		return 0;
	}
	for(ll i = k+1;i<=n;i++){
		ll x = n/i;
		ans+=x*(i-k);
		p=max(q,n-(x*i)-k+1);
		ans+=p;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N==25)
  {
    cout << "Christmas" << endl;
  }
  else if(N==24)
  {
    cout << "Christmas Eve" << endl; 
  }
  else if(N==23)
  {
    cout << "Christmas Eve Eve" << endl;
  }
  else
  {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, a[100000];
    bool up = 1;
    cin >> n;
    for (int i(0); i < n; i++)
    {
        cin >> a[i];
        if (i)
        {
            if (a[i] < a[i - 1] - 1)
            {
                cout << "No";
                return 0;
            }
            if (a[i] < a[i - 1])
            {
                if (!up)
                {
                    cout << "No";
                    return 0;
                } else {
                    up = 0;
                }
            }
            if (a[i] > a[i - 1])
                up = 1;
        }
    }
    cout << "Yes";
    return 0;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
//const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
ll dp[105][4][4][4];

int main()
{
	int N;
	cin>>N;
	dp[0][0][0][0] = 1;
	rep(i, 0, 4)
		rep(j, 0, 4)
			rep(k, 0, 4) 
			{
                if (i == 1 && j == 0 && k == 2) continue;
                if (i == 0 && j == 1 && k == 2) continue;
                if (i == 0 && j == 2 && k == 1) continue;
                dp[3][i][j][k] = 1;
            }

	rep(n, 3, N)
		rep(i, 0, 4)
			rep(j, 0, 4)
				rep(k, 0, 4)
					rep(l, 0, 4)
					{
						if(i == 0 && k == 1 && l == 2) continue;
						if(i == 0 && j == 1 && l == 2) continue;
						if(j == 0 && k == 1 && l == 2) continue;
						if(j == 0 && k == 2 && l == 1) continue;
						if(j == 1 && k == 0 && l == 2) continue;
						dp[n+1][j][k][l] = (dp[n+1][j][k][l] + dp[n][i][j][k])%M;
					}
	ll ans = 0;
	rep(i, 0, 4)
		rep(j, 0, 4)
			rep(k, 0, 4)
				ans = (ans + dp[N][i][j][k])%M;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

void solve() {
	int n;
	cin >> n;

	vector<int> a(n);

	for(auto& elem: a) {
		cin >> elem;
	}

	int answ = 0;

	for(;;) {
		int found = 0;

		for(int i = 0; i < n;) {
			if(a[i] == 0) {
				++i;
				continue;
			}

			int j = i;

			while(j + 1 < n && a[j + 1] > 0)
				++j;

			for(int pos = i; pos <= j; ++pos) {
				--a[pos];
			}

			++answ;
			found = 1;
			i = j + 1;
		}

		if(found == 0)
			break;
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 256