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

typedef long long ll;

int n, t[555][555], r[555][555];

void f(int y, int x){
    bool b=0;
    if (y>1){
        if ((t[y-1][x]+r[y-1][x])<t[y][x]){
            b=1;
            t[y][x]=t[y-1][x]+r[y-1][x];
        }
    }
    if (y<n){
        if ((t[y+1][x]+r[y+1][x])<t[y][x]){
            b=1;
            t[y][x]=t[y+1][x]+r[y+1][x];
        }
    }
    if (x>1){
        if ((t[y][x-1]+r[y][x-1])<t[y][x]){
            b=1;
            t[y][x]=t[y][x-1]+r[y][x-1];
        }
    }
    if (y<n){
        if ((t[y][x+1]+r[y][x+1])<t[y][x]){
            b=1;
            t[y][x]=t[y][x+1]+r[y][x+1];
        }
    }
    if (b){
        if (y>1) f(y-1, x);
        if (y<n) f(y+1, x);
        if (x>1) f(y, x-1);
        if (x<n) f(y, x+1);
    }
}

int main(){
    ll ans=0;
    cin >> n;
    for (int i=1; i<=n; ++i){
        for (int j=1; j<=n; ++j){
            r[i][j]=1;
            t[i][j]=min(min(i-1, (n-i)), min(j-1, (n-j)));
        }
    }
    for (int i=1; i<=n*n; ++i) {
        int a;
        cin >> a;
        int y, x;
        y=(a-1)/n;
        y++;
        x=a%n;
        if (x==0) x=n;
        ans+=t[y][x];
        r[y][x]=0;
        if (y>1) f(y-1, x);
        if (y<n) f(y+1, x);
        if (x>1) f(y, x-1);
        if (x<n) f(y, x+1);
    }
    cout << ans << "\n";
}



Measured memory_bytes: 35904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0) break;

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ll f = A[i - 1];
        ll b = A[i];
        ll diff = f - b;
        diff = 0 <= diff ? diff : 0;
        ans += diff;
        A[i] += diff;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
    int n;
    while(cin >> n, n){
        int data[10000];
        int need;
        for(int i=0; i < n; i++)
            cin >> data[i];
        cin >> need;

        int before = 0, after = n-1;
        int cnt = 0;
        while(before <= after){
            int mid = (after + before) / 2;
            cnt++;
            if(need == data[mid])
                break;
            if(data[mid] > need)
                after = mid-1;
            else
                before = mid+1;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>

int main(void)

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a>b) printf("a > b\n");

    else if(a<b) printf("a < b\n");

    if(a==b) printf("a == b\n");

    return 0;

}
 

Measured memory_bytes: 1008
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	int a,b;cin>>a>>b;
	ll x=a*2;
	ll y=a*4;
	if(b>=x && b<=y && b%2==0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}






}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int r;
  for(int i=0;i<3;i++){
    if(a[i]!=b[2-i]){
      cout<<"NO";
      return 0;
    }
  }
  cout<<"YES";
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B){
    cout << (A*B) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 2000000000000000000 //1e16
 
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T; 
    // int x1,y1,x2,y2,z1,z2;
    cin>>n>>k>>t;
    cout<<t*((n+k-1)/k);
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main (void)
{
    int N, T, c, t;
    int i;
    int ans = 1001;

    scanf("%d %d", &N, &T);

    for(i = 0; i < N; i++) {
        scanf("%d %d", &c, &t);
        if (t <= T && c < ans) ans = c;
    }

    if (ans > 1000) {
        puts("TLE");
    } else {
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) cnt += (i % j == 0);
        ans += cnt == 8;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func main() {
	defer write.Flush()

	var a, b, k int64
	fmt.Fscan(read, &a, &b, &k)

	a, k = a-min(a, k), max(0, k-a)
	b, k = b-min(b, k), max(0, k-b)
	fmt.Fprintln(write, a, b)
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/22/20 21:00:03
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  map<pair<int, int>, int> wb, ww;
  vector<vector<int>> bgrid(4*k, vector<int>(4*k, 0));
  auto wgrid = bgrid;
  for (int i = 0; i < n; i++) {
    int x,y; cin>>x>>y;
    x=x%(2*k);
    y=y%(2*k);
    char c; cin>>c;
    if (c=='B') {
      bgrid[k+x][k+y]++;
    } else {
      wgrid[k+x][k+y]++;
    }
  }
  auto set_grid = [k](auto& grid) {
    for (int i = k; i < 4*k; i++) {
      for (int j = k; j < 4*k; j++) {
        grid[i][j] += grid[i-1][j];
        grid[i][j] += grid[i][j-1];
        grid[i][j] -= grid[i-1][j-1];
      }
    }
    for (int i = 4*k-1; i >= k; i--) {
      for (int j = 4*k-1; j >= k; j--) {
        grid[i][j] += -grid[i-k][j] - grid[i][j-k] + grid[i-k][j-k];
      }
    }
  };
  set_grid(bgrid);
  set_grid(wgrid);
  auto area_sum = [](int x, int y, auto& grid) -> int {
    return grid[x][y];
  };
  int ans = 0;
  for (int i = k; i < 2*k; i++) {
    for (int j = k; j < 2*k; j++) {
      for (int ltb = 0; ltb < 2; ltb++) {
        bool bw = ltb;
        auto& ag = bw?bgrid:wgrid;
        auto& bg = bw?wgrid:bgrid;
        int res = 0;
        res += area_sum(i-1, j-1, ag);
        res += area_sum(i-1, j+2*k-1, ag);
        res += area_sum(i+k-1, j+k-1, ag);
        res += area_sum(i+2*k-1, j-1, ag);
        res += area_sum(i+2*k-1, j+2*k-1, ag);
        res += area_sum(i-1, j+k-1, bg);
        res += area_sum(i+k-1, j-1, bg);
        res += area_sum(i+k-1, j+2*k-1, bg);
        res += area_sum(i+2*k-1, j+k-1, bg);
        ans = max(ans, res);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 125568
#include <iostream>
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int cntRed[4005];
int cntGreen[4005];
int cntBlue[4005];
int main()
{
 
    int n;
    string s;
    cin >> n >> s;
    ll sum = 0 ;
 
    for(int i = 0 ; i<n ; i++){
        if(s[i] == 'R'){
            cntRed[i]++;
        }
        if(s[i] == 'G'){
            cntGreen[i]++;
        }
        if(s[i] == 'B'){
            cntBlue[i]++;
        }
 
        if(i>0){
            cntRed[i] += cntRed[i-1];
            cntBlue[i] +=cntBlue[i-1];
            cntGreen[i] += cntGreen[i-1];
        }
    }
 
    for(int i = 0 ; i<n ; i++){
        for(int j = i+1 ; j<n ; j++){
 
            char c1 = s[i];
            char c2 = s[j];
            if(c1 =='R' && c2 == 'G' || c1 == 'G' && c2 == 'R'){
 
                ll x = cntBlue[n-1] - cntBlue[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='B')sum--;
 
            }
            else if(c1 =='R' && c2 == 'B' || c1 == 'B' && c2 == 'R'){
 
                ll x = cntGreen[n-1] - cntGreen[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='G')sum--;
 
            }
            else if(c1 =='B' && c2 == 'G' || c1 == 'G' && c2 == 'B'){
 
                ll x = cntRed[n-1] - cntRed[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='R')sum--;
            }
        }
    }
 
    printf("%lld\n" , sum);
    return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, i, j, x, cnt=0;
	vector <int> v;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> x;
		v.push_back(x);
	}
	i=0; j=0;
	while(i < v.size() && j < v.size()){
		if(j+1 < v.size() && v[j+1] == v[j])
			j++;
		else{
			cnt += (j-i+1)/2;
			i=j+1;
			j=i;
		}
					
	}
	cout << cnt << endl;

}


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

#define ll long long int
#define endl '\n'
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

ll MIN(ll a, ll b) {
    if(a<b) return a;   return b;
}

ll MAX(ll a, ll b) {
    if(a>b) return a;   return b;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double r;
    cin>>r;
    
    cout<<fixed;
    cout<<setprecision(10)<<2*3.1415926535*r;
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3800
while True:
    solution = 0
    x = input()
    if int(x) == 0:
        break
    elif 0 < int(x) and int(x) < 10:
        print(x)
    else:
        list_x = list(x)
        list_x = [int(s) for s in list_x]
        for i in list_x:
            solution += int(i)
        print(solution)


Measured memory_bytes: 5612
#include <stdio.h>

typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int n;
    int a[200];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }

    quicksort(a, 0, n-1);
    int alice = 0, bob = 0;
    for(int i = n - 1; i >= 0; i -= 2){
        alice += a[i];
        if(i - 1 >= 0) bob += a[i-1];
    }

    printf("%d\n", alice - bob);

    return 0;
}

Measured memory_bytes: 1676
let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    console.log(calc(inputString[0].split(' ')));
});

const calc = (arr) => {
  const stack = [];
  for (let i=0; i<arr.length; i++) {
    const v = arr[i];
    switch (v) {
      case '+':
        stack.push(Number(stack.pop()) + Number(stack.pop()));
        break;
      case '-':
        const a = stack.pop();
        const b = stack.pop();
        stack.push(Number(b) - Number(a));
        break;
      case '*':
        stack.push(Number(stack.pop()) * Number(stack.pop()));
        break;
      default:
        stack.push(v);
    }
  }
  return stack.pop();
};



Measured memory_bytes: 19412
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007

int main(){
	long long n , a , b;
	cin >> n >> a >> b;
	if(a > b) swap(a , b);
	if(a % 2 == b % 2){
		cout << (b - a) / 2 << endl;
		return 0;
	}
	long long cur = a - 1;
	long long tmp = b - cur;
	if(tmp % 2 != 1){
		cur++;
		tmp--;
	}
	cur += (tmp - 1) / 2;
	long long ans = cur;
	cur = n - b;
	tmp = a + cur;
	if(tmp % 2 != n % 2){
		tmp++;
		cur++;
	}
	cur += (n - tmp) / 2;
	ans = min(ans , cur);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int n;
	ll a[200000];
	ll b[200001];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",a+i);
	for(int i=0;i<=n;i++){
		if(i==0) b[i] = 0;
		else b[i] = b[i-1] + a[i-1];
	}
	ll ans = 0;
	sort(b,b+n+1);
	ll cur = 0;
	for(int i=0;i<=n;i++){
		cur++;
		if(i==n||b[i+1]!=b[i]){
			ans += cur * (cur - 1) / 2;
			cur = 0;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;


namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var L = Console.ReadLine();
            int len = L.Length;

            var dp = new long[len + 1, 2];
            for (var i = 0; i <= len; i++) 
            {
                dp[i, 0] = 0;
                dp[i, 1] = 0;
            }
            dp[0, 0] = 1L;

            for(var i = 0; i < len; i++)
            {
                dp[i + 1, 1] = (dp[i + 1, 1] + (dp[i, 1] * 3L)) % MOD;

                if (L[i] == '0')
                {
                    dp[i + 1, 0] = (dp[i + 1, 0] + dp[i, 0]) % MOD;
                }
                else
                {
                    dp[i + 1, 0] = (dp[i + 1, 0] + (dp[i, 0] * 2L)) % MOD;
                    dp[i + 1, 1] = (dp[i + 1, 1] + dp[i, 0]) % MOD;
                }
            }

            Console.WriteLine((dp[len, 0] + dp[len, 1]) % MOD);
        }
    }

   


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int r = 0, w = 0;
	rep(i, s.size()) if (s[i] == 'R') r++;
	int ans = r;
	rep(i, s.size()) {
		if (s[i] == 'R') r--;
		else w++;
		int t = max(r, w);
		ans = min(ans, t);
	}
	cout << ans << endl;
	return 0;
}

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

template<typename T>
struct segment_tree{
    function<T(T,T)> f = [](T a, T b){return min(a,b);};
    T inf=INT_MAX;
    vector<T> value;
    int N;
    segment_tree(int n){
        N=1;
        while(N<n)N*=2;
        value.assign(2*N-1,inf);
    }
    segment_tree(int n, function<T(T,T)> func, T t1){
        N=1;
            while(N<n)N*=2;
        value.assign(2*N-1,t1);
        f=func;
        inf=t1;
    }
    void update(int i,T x){
        i+=N-1;
        value[i]+=x;
        while(i>0){
            i=(i-1)/2;
            value[i]=f(value[i*2+1],value[i*2+2]);
        }
    }
    T query(T a,T b){
        return query(a,b,0,0,N);
    }
    T query(T a,T b, int k, int l, int r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b){
            return value[k];
        }else{
            ll c1=query(a,b,2*k+1,l,(l+r)/2);
            ll c2=query(a,b,2*k+2,(l+r)/2,r);
            return f(c1,c2);
        }
    }
    void print(){
        for(int i=0;i<ceil(log2(N))+1;i++){
            for(int j=0;j<(1<<i);j++){
                cout<<value[j+(1<<i)-1]<<((j==(1<<i)-1)?"":",");
            }
            cout<<endl;
        }
    }
};

int main(){
    ll n,q;
    cin>>n>>q;
    segment_tree<ll> tree(n,[](ll a,ll b){return a+b;},0);
    rep(i,q){
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0){
            tree.update(x-1,y);
        }else{
            cout<<tree.query(x-1,y)<<endl;;
        }
    }
}



Measured memory_bytes: 4868
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;

// A - Add Sub Mul
int main(){
    int A, B;
    cin >> A >> B;
    int calc[3] = {A+B, A-B, A*B};
    int ans=calc[0];
    for(int i=0;i<3;++i){
        if(ans<calc[i]){
            ans = calc[i];
        }
    }
    cout << ans << endl;
    return 0;
}




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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

void solve() {
  ll A, B;
  cin >> A >> B;
  cout << (A * B) / gcd(A, B) << endl;
}

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

  solve();

  return 0;
}


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

using namespace std;

int main() {
  int K, A, B;
  
  cin >> K >> A >> B;
  
  int ans = ceil((double)A / K) * K;
  
  if (A <= ans && ans <= B) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    if (n % 2 == 1L) {
        println(0)
    } else {
        var ans = 0L
        var m = n / 2
        while (m > 0) {
            ans += m / 5
            m /= 5
        }
        println(ans)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

vector<int> li={2,5,5,4,5,6,3,7,6};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> da(m);
    for(int i=0;i<m;i++){
        cin >> da.at(i);
    }
    sort(da.begin(),da.end());
    vector<int> dp(n+1,-100000);
    dp[0]=0;
    for(int i=0;i<n+1;i++){
        for(int j=0;j<m;j++){
            if(i-li.at(da.at(j)-1)>-1){
                dp[i]=max(dp[i],dp[i-li[da[j]-1]]+1);
            }
        }
    }
    vector<int> ans(dp[n]);
    int no=n;
    for(int i=0;i<dp[n];i++){
        for(int j=0;j<m;j++){
            if(no+1>li[da[m-j-1]-1]){
                if(dp[no-li[da[m-j-1]-1]]==dp[n]-i-1){
                    ans[i]=da[m-j-1];
                    no-=li[da[m-j-1]-1];
                    break;
                }
            }
        }
        //cout << no << endl;
    }
    for(int i=0;i<dp[n];i++){
        cout << ans[i];
    }
    cout << endl;
    /* for(int i=0;i<n+1;i++){
        cout << dp[i] << endl;
    }*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
#define pb push_back
#define gc getchar
template<class T>void in(T &x)
{
    x = 0; bool f = 0; char c = gc();
    while (c < '0' || c > '9') {if (c == '-') f = 1; c = gc();}
    while ('0' <= c && c <= '9') {x = (x << 3) + (x << 1) + (c ^ 48); c = gc();}
    if (f) x = -x;
}
#undef gc
#define N 200010
#define M N<<3
#define int ll
struct Edge {
    int u, v, w, nx;
    Edge() {}
    Edge(int uu, int vv, int ww, int nxt) {
        u = uu, v = vv, w = ww, nx = nxt;
    }
    friend bool operator<(const Edge& a, const Edge& b) {
        return a.w < b.w;
    }
} edge[M];
int cnt, head[M];
il void add(int u, int v, int w) {
    edge[++cnt] = Edge(u, v, w, head[u]);
    head[u] = cnt;
}
int f[N];
int find(int x) {
    return x == f[x] ? x : f[x] = find(f[x]);
}
bool cmpy(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx == fy) return 0;
    if (fy > fx) f[fy] = fx;
    else f[fx] = fy;
    return 1;
}
int n, q;
int d[N];
signed main() {
    in(n), in(q);
    mem1(d);
    for (ri i = 1, a, b, c; i <= q; ++i) {
        in(a), in(b), in(c);
        add(a, b, c);
        d[a] = min(d[a], c + 1);
        d[b] = min(d[b], c + 2);
    }
    for (ri i = 0; i < n; ++i) {
        d[i] = min(d[i], d[(i - 1 + n) % n] + 2);
    }
    for (ri i = 0; i < n; ++i) {
        d[i] = min(d[i], d[(i - 1 + n) % n] + 2);
    }
    for (ri i = 0; i <= n; ++i) {
        add(i, (i + 1) % n, d[i]);
    }
    sort(edge + 1, edge + 1 + cnt);
    for (ri i = 1; i < n; ++i) f[i] = i;
    int lt = n, ans = 0;
    for (ri i = 1; i <= cnt && lt > 1; ++i) {
        if (cmpy(edge[i].u, edge[i].v)) {
            ans += edge[i].w;
            --lt;
        }
    }
    printf("%lld", ans);
    return 0;
}

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

typedef long long ll;
ll a[10005];
ll dp[10005]={0};
ll mod=998244353;

int main()
{
	ll n,s;
	cin>>n>>s;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		for(ll j=s;j>=0;j--){
			dp[j]=(dp[j]*2)%mod;
			if(j>=a[i]){
				dp[j]=(dp[j]+dp[j-a[i]])%mod;
			}
			if(j==a[i]){
				dp[j]=(dp[j]+1)%mod;
			}
			if(j==0){
				dp[j]=(dp[j]+1)%mod;
			}
		}
	}
	cout<<dp[s]<<endl;
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define M 1000002
vector<long long >primes;
bool marked[M];

void sieve(long long  n)
{

    for (long long  i = 3; i * i <= n; i += 2)
    {
        if (marked[i] == false)   // i is a prime
        {
            for (long long  j = i * i; j <= n; j += i )
            {
                marked[j] = true;
            }
        }
    }
    primes.push_back(2);
    for(long long i=3; i<=n; i+=2)
    {
        if(marked[i]==false)
            primes.push_back(i);
    }
}

int main()
{
    long long  n;
    cin>>n;
    sieve(100500);

    vector<long long>:: iterator it = lower_bound(primes.begin(),primes.end(),n);
    cout<<*it<<endl;

    return 0;
}


Measured memory_bytes: 3840
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int H, W; cin >> H >> W;
  int A[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
    //keep moving until the elements are even or or has reached the bottom last corner
  vector <Pii> ans1, ans2;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (A[i][j] % 2 == 0) continue;
      else{
        if (j < W - 1){
          ans1.push_back(make_pair(i, j));
          ans2.push_back(make_pair(i, j + 1));
          A[i][j]--; A[i][j + 1]++;
        }else{
          if (i == H - 1) continue;
          A[i][j]--; A[i + 1][j]++;
          ans1.push_back(make_pair(i, j));
          ans2.push_back(make_pair(i + 1, j));
        }
      }
    }
  }
  
  cout << ans1.size() << endl;
  for (int i = 0; i < ans1.size(); i++){
    cout << ans1[i].first + 1 << " " << ans1[i].second + 1 << " ";
    cout << ans2[i].first + 1 << " " << ans2[i].second + 1 << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 5228
n = int(input())

a = 0
b = 0

for i in range(n):
    x, y = map(str,input().split())
    if(x < y):
        b = b + 3
    elif(x > y):
        a = a + 3
    else:
        a = a + 1
        b = b + 1
        
print(a, b)


Measured memory_bytes: 5596
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	int n,m;
	string x[1005];
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> x[i];
	string p[2];
	cin >> p[0] >> p[1];
	int res = 0;
	int sum = 0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<m-1;j++)
		{
			if(x[i][j] == p[0][0] && x[i][j+1] == p[0][1]
			&& x[i+1][j] == p[1][0] && x[i+1][j+1] == p[1][1])
			{
				sum++;
			}
		}
	}
	res = sum;
	char c[3]={'J','O','I'};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(x[i][j] == c[k]) continue;
				char pp = x[i][j];
				int add = 0;
				if(i>0 && j>0)
				{
					add -= (x[i-1][j-1]==p[0][0]&&x[i-1][j]==p[0][1]&&x[i][j-1]==p[1][0]&&x[i][j]==p[1][1]);
				}
				if(i>0)
				{
					add -= (x[i-1][j]==p[0][0]&&x[i-1][j+1]==p[0][1]&&x[i][j]==p[1][0]&&x[i][j+1]==p[1][1]);
				}
				if(j>0)
				{
					add -= (x[i][j-1]==p[0][0]&&x[i][j]==p[0][1]&&x[i+1][j-1]==p[1][0]&&x[i+1][j]==p[1][1]);
				}
				{
					add -= (x[i][j]==p[0][0]&&x[i][j+1]==p[0][1]&&x[i+1][j]==p[1][0]&&x[i+1][j+1]==p[1][1]);
				}
				x[i][j] = c[k];
				if(i>0 && j>0)
				{
					add += (x[i-1][j-1]==p[0][0]&&x[i-1][j]==p[0][1]&&x[i][j-1]==p[1][0]&&x[i][j]==p[1][1]);
				}
				if(i>0)
				{
					add += (x[i-1][j]==p[0][0]&&x[i-1][j+1]==p[0][1]&&x[i][j]==p[1][0]&&x[i][j+1]==p[1][1]);
				}
				if(j>0)
				{
					add += (x[i][j-1]==p[0][0]&&x[i][j]==p[0][1]&&x[i+1][j-1]==p[1][0]&&x[i+1][j]==p[1][1]);
				}
				{
					add += (x[i][j]==p[0][0]&&x[i][j+1]==p[0][1]&&x[i+1][j]==p[1][0]&&x[i+1][j+1]==p[1][1]);
				}
				res = max(res,sum+add);
				x[i][j] = pp;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 2256
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 1000 + 7;

char S[MAX_N];

int main() {
  RI(S);
  int N = strlen(S);
  int a = 0, b = 0, c = 0, d = 0;
  REP(i, N) {
    if (S[i] == 'N') a = 1;
    if (S[i] == 'S') b = 1;
    if (S[i] == 'E') c = 1;
    if (S[i] == 'W') d = 1;
  }
  PL(a == b && c == d ? "Yes" : "No");
  return 0;
}



Measured memory_bytes: 256
while(1):
    [W,Q]=map(int,raw_input().split())
    if W==0 and Q==0: break
    se=[(0,0),(W,W)]
    idq=[10000,100001]
    for i in range(Q):
        S=raw_input().split()
        Sn=[int(x) for x in S[1:]]
        if S[0]=='s':
            for i in range(len(se)-1):
                if se[i+1][0]-se[i][1]>=Sn[1]:
                    print se[i][1]
                    se.insert(i+1,(se[i][1],se[i][1]+Sn[1]))
                    idq.insert(i+1,Sn[0])
                    break
            else:
                print 'impossible'
        if S[0]=='w':
            i=idq.index(Sn[0])
            del se[i]
            del idq[i]
    print 'END'

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

string a,b,c;

string form (string s) {
  transform(s.begin(), s.end(), s.begin(), ::toupper);
  return s;
}

int main(){
  cin >> a >> b >> c;
  a = form(a);
  b = form(b);
  c = form(c);

  cout << a.front() << b.front() << c.front() << "\n";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val inputs = readLine()!!.split(" ").map { it.toLong() }

    // n < 50, k < 100
    // 全探索で行けそうな感じがする

    var maxScore = Long.MIN_VALUE
    // WA : 0 until 4 とすると，１つも取らない　~ ３つ取る までで, 4つとる場合を表現できてなかった
    for (i in 0 until Math.min(n, k) + 1) {
        //　i 個取ると決めたとき左から何個と右から何個を取るか
        // WA : 0 until 4 とすると，１つも取らない　~ ３つ取る までで, 左から4つすべて取る場合を考えられない
        for (j in 0 until i + 1) {

            var bag = mutableListOf<Long>()

            // 左から j 個
            val left = inputs.subList(0, j).toMutableList()

            // 右から i - j 個
            val right = inputs.subList(inputs.size - (i - j), inputs.size)

            bag.addAll(left)
            bag.addAll(right)
            bag.sort()

            // 戻す操作
            for (k in 0 until Math.max(0, k - i)) {
                if (bag.size == 0 ){
                    break
                }

                if (bag[0] < 0) {
                    bag.removeAt(0)
                } else {
                    break
                }
            }

            if (bag.sum() > maxScore){
                maxScore = bag.sum()
            }
        }
    }

    println(maxScore)
}

Measured memory_bytes: 41120
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0] * N

for i,H in enumerate(h):
  if i != 0:
    j=0 if i<K else i-K
    dp[i] = min(k + abs(l-H) for k,l in zip(dp[j:i], h[j:i]))
print(dp[-1])

Measured memory_bytes: 13928
n = int(input())
a = list(map(int,input().split(" ")))

for i in range(n):
    a[i] = a[i] - i -1

a.sort()

if n%2 == 1:
    med = a[int((n-1)/2)]
else:
    med = a[int(n/2)]
ans = 0
for i in range(n):
    ans += abs(a[i]-med)

print(ans)

Measured memory_bytes: 25196
import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools,itertools,operator,bisect,fractions
from collections import deque,defaultdict,OrderedDict,Counter
from fractions import Fraction
from decimal import Decimal
    
def main():
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    
    for _ in range(1):
        n=ri()
        c=0
        z=0
        for i in range(n):
            a,b=ria()
            if a==b:
                c+=1
            else:
                c=0
            z=max(z,c)
        if z>=3:
            print('Yes')
        else:
            print('No')
        
        
        
    
    
        
                    
        
    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")  
    
                
class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()


class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)


class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush


if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()







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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		long n = Long.parseLong(str);
		System.out.print(n + ":");
		long div = n;
		Boolean isBig = true;
		for (long i = 2; isBig; i++) {
			if (div % i == 0) {
				div = div / i;
				System.out.print(" " + i);
				i--;
			}
			isBig = i < Math.pow(div, 0.5);
		}
		if (div != 1) {
			System.out.println(" " + div);
		} else {
			System.out.println();
		}
	}
}

Measured memory_bytes: 24248
#include<stdio.h>
#include<math.h>
int Sosu(int N){
  int i=3;
if(N==2)return 1;
if(N<2 || N%2==0)return 0;
while(i<=sqrt(N)){
  if(N%i==0)return 0;
  i=i+2;
}
return 1;
}
int main(void){
int N;
int n,i;
int S=0,c=0;
while(1){
scanf("%d",&n);
if(n>=1 && n<=10000)break;
}
for(i=0 ; i<n ; i++){
  while(1){
  scanf("%d",&N);
  if(N>=2 && N<=100000000)break;
  }
  S+=Sosu(N);
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
string s;
int d;
const int mod=1000000007;
int dp[10002][102][2];
int f(int pos,int m,int b){
	if(pos==s.size()){
		return m==0;
	}
	int &ans=dp[pos][m][b];
	if(~ans)return ans;
	ans=0;
	if(b)
	{
		for(int i=0;i<10;i++){
			ans+=f(pos+1,(m+i)%d,b);
			if(ans>=mod)ans-=mod;
		}
	}else{
		for(int i=0;i<s[pos]-'0';i++){
			ans+=f(pos+1,(m+i)%d,1);
			if(ans>=mod)ans-=mod;
		}
		ans+=f(pos+1,(m+s[pos]-'0')%d,0);
		if(ans>=mod)ans-=mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp,-1,sizeof dp);
	cin>>s>>d;
	int ans=f(0,0,0)-1;
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8960
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

// https://github.com/yambe2002/topcoder_template/blob/master/MyLibrary.cs
public class PriorityQueue<T> where T: IComparable
{
    private int _type = 0;
    private T[] _heap;
    private int _sz = 0;
    private int _count = 0;

    /// <summary>
    /// Priority queue
    /// </summary>
    /// <param name="type">0: asc, 1:desc</param>
    public PriorityQueue(int type = 0)
    {
	_heap = new T[128];
	_type = type;
    }

    private int Compare(T x, T y)
    {
	return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
    }

    public void Push(T x)
    {
	_count++;
	if (_count > _heap.Length)
	{
	    var newheap = new T[_heap.Length * 2];
	    for (int n = 0; n < _heap.Length; n++) newheap[n] = _heap[n];
	    _heap = newheap;
	}

	//node number
	var i = _sz++;

	while (i > 0)
	{
	    //parent node number
	    var p = (i - 1) / 2;
	    
	    if (Compare(_heap[p], x) <= 0) break;

	    _heap[i] = _heap[p];
	    i = p;
	}

	_heap[i] = x;
    }

    public T Pop()
    {
	_count--;

	T ret = _heap[0];
	T x = _heap[--_sz];

	int i = 0;
	while (i * 2 + 1 < _sz)
	{
	    //children
	    int a = i * 2 + 1;
	    int b = i * 2 + 2;

	    if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;

	    if (Compare(_heap[a], x) >= 0) break;
	    
	    _heap[i] = _heap[a];
	    i = a;
	}

	_heap[i] = x;

	return ret;
    }

    public int Count(){ return _count; }
    public T Peek(){ return _heap[0]; }
}

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];

	Tuple<int,int>[] d = new Tuple<int,int>[n];
	for (int i = 0; i < n; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1];
	    d[i] = new Tuple<int,int>(a, b);
	}
	Array.Sort(d);

	PriorityQueue<int> q = new PriorityQueue<int>(1);

	long ans = 0;
	int idx = 0;
	for (int i = 1; i <= m; i++)
	{
	    while (idx < d.Length && d[idx].Item1 <= i)
	    {
		q.Push(d[idx].Item2);
		idx++;
	    }
	    if (q.Count() > 0){ ans += q.Pop(); }
	}

	WriteLine(ans);
    }
}


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


const ll INF = 1e18;

ll knapsack2(int n, int W){
    
    ll weight[n] = {};
    ll value[n] = {};
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }
    
    int val_sum = 0;
    for(int x : value) val_sum += x;

    // 2-D array solving

    // vector<vector<ll>> dp(n+1,vector<ll>(val_sum+1,INF));
    // dp[0][0] = 0;
    // for(int i = 1; i <= n; i++){
        
    //     for(int j = 0; j < value[i-1]; j++) dp[i][j] = dp[i-1][j];
    //     for(int j = val_sum; j >= value[i-1]; j--){
    //         dp[i][j] = min(dp[i-1][j], weight[i-1] + dp[i-1][j-value[i-1]]);
    //     }
        
    // }
    
    // ll ans = 0;
    // for(ll j = 0; j <= val_sum; j++){
    //     if(dp[n][j] <= W) ans = max(ans, j);
    // }
    
    
    // 1d array solving
    vector<ll>dp(val_sum+1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = val_sum; j >= value[i]; j--){
            dp[j] = min( dp[j] , (dp[j-value[i]]+weight[i]));
            
        }
    }
    
    ll ans = 0;
    for(ll j = 0 ; j <= val_sum; j++){
        if(dp[j] <= W) ans = max(ans,j);
    }
    
    
    return ans;
}
 
 
int main(){
    int n,W ; cin >> n >> W;
    cout << knapsack2(n,W) ;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x;
	cin >> x;

	vector<bool> f(x + 1);

	f[1] = true;
	for (int i = 2; i <= x; i++) {
		int b = i * i;
		while (b <= x) {
			f[b] = true;
			b *= i;
		}
	}

	for (int i = x; i >= 1; i--) {
		if (f[i]) {
			out(i);
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int SIZE = 8;
vector<vector<int>> T(SIZE);
int dfs(int v,int n,int visited){
   bool flag = true;
   if (visited == (1<<n)-1){
      return 1;
   }
   int ret = 0;
   for (auto &&i : T[v]){
      if (1<<i & visited)continue;
      visited = visited ^ (1<<i);
      ret += dfs(i,n,visited);
      visited = visited ^ (1<<i);
   }
   return ret;
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n,m; cin >> n >> m;
   rep(i,m){
      int a, b; cin >> a >> b;
      a--;b--;
      T[a].push_back(b);
      T[b].push_back(a);
   }
   cout << dfs(0,n,1) << endl;
}

Measured memory_bytes: 3652