akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			bool[] pb = Enumerable.Repeat(true, 10001).ToArray();
			pb[0] = pb[1] = false;
			for (int i = 2; i < Math.Sqrt(pb.Length); i++)
				if (pb[i])
					for (int j = i * 2; j < pb.Length; j++)
						if (j % i == 0)
							pb[j] = false;

			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				for (int i = n; i >= 5; i--)
				{
					if (pb[i] && pb[i - 2])
					{
						Console.WriteLine("{0} {1}", i - 2, i);
						break;
					}
				}
			}
		}
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Nice Shopping
            var line = ReadLine();
            int A = line[0];
            int B = line[1];
            int M = line[2];

            var a = ReadLine();
            var b = ReadLine();

            int min = a.Min() + b.Min();

            for(int i = 0; i < M; i++)
            {
                line = ReadLine();
                int x = line[0] - 1;
                int y = line[1] - 1;
                int c = line[2];

                var price = a[x] + b[y] - c;
                min = Math.Min(min, price);
            }

            Console.WriteLine(min);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 39388
from collections import Counter 

n = int(input())
aa = list(map(int,input().split()))

c = Counter(aa)

ans = 0
for k,count in c.items():
  if k > count:        
    ans += count
  elif k == count:    
    pass
  else:        
    ans += count - k    
    
print(ans)      

Measured memory_bytes: 18676
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return float('inf')
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> a(n,0);
    for(int i = 0;i < k;i++){
        int d;
        cin >> d;
        vector<int> b(d,0);
        for(int i = 0;i < d;i++){
            cin >> b[i];
            a[b[i] - 1]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] == 0) ans++;
    }
    cout << ans << endl;
}


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

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

  int a = n / 1000;
  int b = n % 1000;

  if (b > 0) {
    a++;
  }

  cout << ((a * 1000) - n) << endl;
  return 0;
}

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


int main() {
	string S; cin >> S;
	S.push_back('I');
	int cnt = 0, max = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			for (int j = i+1; j < S.size(); j++)
			{
				if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T') {
					cnt = j - i;
					break;
				}
			}
		}
		if (max < cnt)max = cnt;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0){
            break;
        }
        else{
            for(int i = 1;i <= b;i++){
                printf("#");
            }
            printf("\n");
            for(int i = 1;i <= a - 2;i++){
                printf("#");
                for(int j = 1;j <= b - 2;j++){
                    printf(".");
                }
                printf("#\n");
            }
            for(int i = 1;i <= b;i++){
                printf("#");
            }
            printf("\n\n");
        }
    }
    return 0;
}


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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 1e5;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

int main() {
  init();
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += com(i, K - 1) * A.at(i);
    ans %= MOD;
    ans -= com(N - i - 1, K - 1) * A.at(i);
    ans %= MOD;
    while (ans < 0) ans += MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6404
# include <iostream>
# include <cstdio>
# include <cmath>  
using namespace std;
int main(void)  
{  
  int nBinary = 0;  
  int nDigital = 1;  
  int nTemp = 0;  
  int nMark = 0;  
  int nNumber = 0;  
  int nNumberArrayOne[10000] = {0};  
  int nNumberArrayTwo[10000] = {0};  
  
  nNumberArrayOne[0] = 2;  
  nNumberArrayTwo[0] = 1;  
  
  scanf("%d", &nNumber);  
  
  for (int i = 1; i < nNumber; i++)  
  {  
    if (nMark == 0)  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayOne[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayOne[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 1;  
    }  
    else  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayTwo[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayTwo[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 0;  
    }  
  }  
  
  if (nMark == 0)  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayTwo[k]);  
    }  
    puts("");  
  }  
  else  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayOne[k]);  
    }  
    puts("");  
  }  
  
  return 0;  
}  


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;

#define MAX_V 210000
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
bool used[MAX_V];
int cmp1[MAX_V];
int cmp2[MAX_V];
int ans[MAX_V];
vector<int>hoge[MAX_V];
void add_edge1(int to,int from){
    G[to].push_back(from);
    G[from].push_back(to);
}
void add_edge2(int to,int from){
    rG[to].push_back(from);
    rG[from].push_back(to);
}
void dfs1(int v,int k){
    stack<int>S;
    S.push(v);
    while(!S.empty()){
        int t = S.top();S.pop();
        used[t]=true;
        cmp1[t] = k;
        rep(i,G[t].size()){
            if(!used[G[t][i]])S.push(G[t][i]);
        }
    }
}
void dfs2(int v,int k){
    stack<int>S;
    S.push(v);
    while(!S.empty()){
        int t = S.top();S.pop();
        used[t]=true;
        cmp2[t] = k;
        rep(i,rG[t].size()){
            if(!used[rG[t][i]])S.push(rG[t][i]);
        }
    }
}
int main(){
    int n,k,l;
    scanf("%d %d %d",&n,&k,&l);
    vector<int>p(k);
    vector<int>q(k);
    vector<int>r(l);
    vector<int>s(l);
    rep(i,k){
        scanf("%d %d",&p[i],&q[i]);
        p[i]--;
        q[i]--;
        add_edge1(p[i],q[i]);
    }
    int temp1 = 0;
    rep(v,n){
        if(!used[v])dfs1(v,temp1++);
    }
    memset(used, 0, sizeof(used));
    rep(i,l){
        scanf("%d %d",&r[i],&s[i]);
        r[i]--;
        s[i]--;
        add_edge2(r[i],s[i]);
    }
    int temp2 = 0;
    rep(v,n){
        if(!used[v])dfs2(v,temp2++);
    }
    map<pii,int>M;
    rep(i,n) M[pii(cmp1[i],cmp2[i])]++;
    rep(i,n){
        if(i<n-1)printf("%d ",M[pii(cmp1[i],cmp2[i])]);
        else printf("%d\n",M[pii(cmp1[i],cmp2[i])]);
            
    }
}

Measured memory_bytes: 35068
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n, d = mi()
    cnt = 0
    d2 = d**2
    for i in range(n):
        x, y = mi()
        if x**2 + y**2 <= d2:
            cnt += 1
    print(cnt)


main()


Measured memory_bytes: 9920
n = int(input())
f = [[0]*10 for _ in range(n)]
p = [[0]*11 for _ in range(n)]
wa = [0]*10
ans = -1000000000000000000000000

for i in range(n):
    f[i] = list(map(int, input().split()))

for i in range(n):
    p[i] = list(map(int, input().split()))

for i in range(2**10):
    if i == 0:
        continue
    pk = 0
    ls = [0,0,0,0,0,0,0,0,0,0]
    for j in range(10):
        if (i >> j) & 1:
            ls[j] = 1
        
    for k in range(n):
        o = 0
        for l in range(10):
            if f[k][l] == 1 and ls[l] == 1:
                o += 1
                
        pk += p[k][o]
        
    ans = max(ans,pk)
    
print(ans)

Measured memory_bytes: 44652
#include<stdio.h>

int main(void){
    int num;
    int t1, t2, t3;
    scanf("%d", &num);
    while(scanf("%d%d%d", &t1, &t2, &t3)!=EOF){
        if(t1>t2 && t1>t3){
            if(t1*t1==t2*t2+t3*t3) printf("YES\n");
            else printf("NO\n");
        }else if(t2>t1 && t2>t3){
            if(t2*t2==t1*t1+t3*t3) printf("YES\n");
            else printf("NO\n");
        }else{
            if(t3*t3==t2*t2+t1*t1) printf("YES\n");
            else printf("NO\n");
        }
    }
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;

namespace ABC063_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = true;
            var str = Console.ReadLine();
            var temp = new List<char>();
            for(var i=0;i<str.Length;i++)
            {
                var c = str[i];
                if (temp.Contains(c)) ans = false;
                temp.Add(c);
            }
            if (ans == true) Console.WriteLine("yes");
            else Console.WriteLine("no");
        }
    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
	int l,r,d;
	cin >> l >> r >>d;
	int ans =0;
	for(int i = l ; i <= r;i++) {
		if (i % d ==0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3160
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine().trim());
        if(n>=1800 && n<=1999){
            System.out.println(1);
        }
        else if(n>=1600 && n<=1799){
            System.out.println(2);
        }
        else if(n>=1400 && n<=1599){
            System.out.println(3);
        }
        else if(n>=1200 && n<=1399){
            System.out.println(4);
        }
        else if(n>=1000 && n<=1199){
            System.out.println(5);
        }
        else if(n>=800 && n<=999){
            System.out.println(6);
        }
        else if(n>=600 && n<=799){
            System.out.println(7);
        }
        else if(n>=400 && n<=599){
            System.out.println(8);
        }

    }


}


Measured memory_bytes: 32548
#include<iostream>
#include<vector>
#include<utility>

int main(){
  std::vector<std::pair<int, int>> v;
  int n,m;
  std::cin>>n>>m;
  if(n==1 && m==0)
    std::cout<<0<<std::endl;
  else{
  int s,c;
  while(m--){
    std::cin>>s>>c;
    v.push_back(std::make_pair(s,c));
  }
  int arr[]={-1,-1,-1};
  bool flag=true;
  for(auto i:v){
    if(i.first==1 && i.second==0 && n>1){
      flag = false;
      break;
    }
    if(arr[i.first-1] == -1)
      arr[i.first-1]=i.second;
    else if(arr[i.first-1] != -1 && arr[i.first-1] != i.second){
      flag=false;
      break;
    }
  }
  if(flag)
  {
    for(int i=0; i<n; ++i){
      if(arr[i]==-1 && i!=0)
        std::cout<<0;
      else if(arr[i]==-1 && i==0)
        std::cout<<1;
      else
        std::cout<<arr[i];
    }
    std::cout<<std::endl;
  }
  else
      std::cout<<"-1"<<std::endl;
}
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[10000][2], a[2000000],b[2000000];
string str, ss,dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<LL>v[21];
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		rep(j, 21) {
			if (a[i] & 1 << j) {
				v[j].push_back(i);
			}
		}
	}
	rep(i, 21) {
		v[i].push_back(n+1);
		v[i].push_back(n+1);
	}
	rep(i, n) {
		LL num = n;
		rep(j, 21) {
			LL itr = upper_bound(v[j].begin(), v[j].end(), i) - v[j].begin();
			if ((a[i] & (1 << j))==0) {
				num = min(num, v[j][itr+1]);
			}
			else {
				num = min(num, v[j][itr]);
			}

		}
		ans += num-i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22388
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz                size()
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define F                 first
#define S                 second
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define fin               freopen( "input.txt", "r", stdin );
#define fout              freopen( "output.txt", "w", stdout );
#define deb(x) cout << #x << " " << x << endl
#define inf INT_MAX
const ll N = 200010;
const ll MOD = 998244353;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}

int minCost(int a[], int n, int k){

    int dp[n];

    dp[0] = 0, dp[1] = abs(a[1]-a[0]);

    for(int i=2;i<n;i++){
        dp[i] = INT_MAX;
    }

    for(int i=2;i<n;i++){
        for(int j=1;j<=min(k,i);j++){
            dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
        }
    }

    return dp[n-1];
}


void solve(){
    
    int n, k;
    cin >> n >> k;
    int a[n];

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

    cout << minCost(a, n, k) <<endl;

}

int main(){
    //fin fout
    fast
    ll T = 1; //cin >> T;
    loop(i, 0, T) solve();
    /*#ifdef LOCAL
    clock_t tStart = clock();
    cerr<<fixed<<setprecision(10)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
    #endif*/
}


/*339 341 1
342 343 2
342 342 2*/



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) {
        cout << s[i];
    }
}


Measured memory_bytes: 256
#import sys
#import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra

#sys.setrecursionlimit(10000)

N, M = [int(i) for i in input().split()]

rows = []
cols = []
weights = []

for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors =True)
#print(d1)
#print(pre)

path = []
for i in range(N):
    for j in range(N):
        if pre[i][j] != -9999:
            if j < pre[i][j]:
                path.append([j,pre[i][j]])
            else:
                path.append([pre[i][j], j])
path = list(map(list, set(map(tuple, path))))
print(M-len(path))

Measured memory_bytes: 25508
n=int(input())
def judge(t_1,x_1,y_1,t_2,x_2,y_2):
    dt=t_2-t_1 
    dx=abs(x_2-x_1) 
    dy=abs(y_2-y_1) 
    if dx+dy>dt:
        return True 
    else: 
        if (dt-dx-dy)%2 == 0:
            return False 
        else: 
            return True 
        
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))
    
t_1,x_1,y_1=0,0,0 
for i in range(n):
    t_2,x_2,y_2=data[i]
    if judge(t_1,x_1,y_1,t_2,x_2,y_2): 
        print("No") 
        break 
    t_1,x_1,y_1=t_2,x_2,y_2 
else: 
    print("Yes")

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

int main(){
  int N,sum,mx;
  sum=0;
  mx=0;
  cin >> N;
  int L[N];
  for (int i=0; i<N; ++i) cin >> L[i];
  for (int i=0; i<N; ++i) sum += L[i];
  for (int i=0; i<N; ++i) mx = max(mx,L[i]);
  if(sum>2*mx)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int train(int t,int C,int S,int F);

int main(void){
    int n,c[500],s[500],f[500];
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    int a;
    for(int i=0;i<n-1;i++){
        a=0;
        for(int j=i;j<n-1;j++){
            a=train(a,c[j],s[j],f[j]);
        }
        cout<<a<<endl;
    }
    cout<<0;
    return 0;
}

int train(int t,int C,int S,int F){
    int ans;
    ans=(max(t,S)-1)/F*F+F+C;
    return ans;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }
    ll L, R;
    cin >> L >> R;
    if (R-L>2019)
        cout << 0 << endl;
    else{
        ll sol = 1ll<<62;
        for(ll i=L; i<=R; i++){
            for(ll j=i+1; j<=R; j++){
                sol = min(sol, i*j % 2019);
            }
        }
        cout << sol << endl;
    }

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>
 
using namespace std;
 
int main(){
    int n;
    double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
    for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
 
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
    }
    printf("%.6lf\n",p_1);
    printf("%.6lf\n",sqrt(p_2));
    printf("%.6f\n",cbrt(p_3));
    printf("%.6lf\n",p_infinity);
 
}




Measured memory_bytes: 2912
#include<iostream>
// #include<vector>
// #include<algorithm>
#include<cmath>
// #include<iomanip>
using namespace std;

// typedef long long ll;
// typedef unsigned long long ull;
// typedef pair<int,int> pii;


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

    int n;
    string s;
    cin>>n>>s;
    int i=0,j=n-1;
    int count = 0;
    while(i<j)
    {
        if(s[i] == 'W' && s[j] == 'R')
        {
            ++count;
            ++i;
            --j;
            continue;
        }
        while(s[i] == 'R') ++i;
        while(s[j] == 'W') --j;
    }
    cout<<count<<"\n";
    return 0;
}

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

int main(){
  int tree,taisho;
  int kekka;
  cin >> tree >> taisho;
  
  kekka = tree / (taisho * 2 + 1);
  if(tree > kekka * (taisho * 2 + 1)) kekka++;
  
  cout << kekka;
}


Measured memory_bytes: 256
from collections import deque
N, Q = map(int, input().split())
count = [0 for i in range(N)]
graph = {i:[] for i in range(N)}

for i in range(N-1):
  a, b = map(int, input().split())
  graph[a-1]+=[b-1]
  graph[b-1]+=[a-1]

for i in range(Q):
  p, x = map(int, input().split())
  count[p-1] += x

q = deque([0])
log = [True]*N
log[0]=False
while q:
  v = q.popleft()
  ls = graph[v]
  for l in ls:
    if log[l]:
      q.append(l)
      log[l]=False
      count[l] += count[v]
print(*count)

Measured memory_bytes: 73200
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int X1, Y1, X2, Y2;

int main(void){
    
    scanf("%d %d %d %d", &X1, &Y1, &X2, &Y2);
    
    int dist1 = X2 - X1, dist2 = Y2 - Y1;
    
    for(int i = 0; i < dist1; ++i) printf("R");
    for(int i = 0; i < dist2; ++i) printf("U");
    for(int i = 0; i < dist1; ++i) printf("L");
    for(int i = 0; i < dist2; ++i) printf("D");
    
    printf("D");
    for(int i = 0; i < dist1 + 1; ++i) printf("R");
    for(int i = 0; i < dist2 + 1; ++i) printf("U");
    printf("L");
    
    printf("U");
    for(int i = 0; i < dist1 + 1; ++i) printf("L");
    for(int i = 0; i < dist2 + 1; ++i) printf("D");
    printf("R\n");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

bool comp(int a, int b) {
	return a > b;
}

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

	int n;
	cin >> n;
	multiset<int> small, large;
	ll sum = 0, m = -inf, ans = 0;
	rep(_, n) {
		int type;
		cin >> type;
		if (type == 1) {
			int a, b;
			cin >> a >> b;
			sum += b;
			if (small.size() == large.size()) {
				if (large.size() == 0 || a <= *large.begin()) small.insert(a);
				else {
					large.insert(a);
					small.insert(*large.begin());
					large.begin() = large.erase(large.begin());
				}
			}
			else {
				auto it = small.end(); it--;
				if (*it <= a) large.insert(a);
				else {
					small.insert(a);
					large.insert(*it);
					it = small.erase(it);
				}
			}
			auto it = small.end(); it--;
			int d = *it;
			if (m > d) ans += m - d;
			m = d;
			ans += abs(m - a);
		}
		else if (type == 2) cout << m << ' ' << ans + sum << '\n';
	}
}

Measured memory_bytes: 9728
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();
        
        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let (n, k) = read_cols!(usize, usize);
    let nums = read_vec::<usize>();

    let mask = (0..40)
        .filter(|i| n > 2 * nums.iter().filter(|&m| ((m >> i) & 1usize) > 0usize).count())
        .fold(0usize, |acc, i| acc + (1usize << i));
    
    let ans:usize = (0..40)
        .map(|i| (k & mask & !((1usize << (i + 1)) - 1)) + (mask & ((1usize << i) - 1)))
        .filter(|&x| x <= k)
        .map(|x| nums.iter().map(|a| a ^ x).sum())
        .max()
        .unwrap();
    
    println!("{}", ans);
}

Measured memory_bytes: 8444
lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
MAX_N = 110000

dp = Array.new(MAX_N, N+1)
dp[0] = 0

for n in 0..N
  pow6 = 1
  loop {
    dp[n+pow6] = [dp[n+pow6], dp[n]+1].min
    pow6 *= 6
    break if n + pow6 > N
  }
  pow9 = 1
  loop {
    dp[n+pow9] = [dp[n+pow9], dp[n]+1].min
    pow9 *= 9
    break if n + pow9 > N
  }
end

puts dp[N]

Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}


int main() {
  int N;
  cin >> N;
  vector<ll> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  
  ll res = vec[0];
  for (int i = 1; i < N; i++) {
    res = gcd(res, vec[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    vector<ll>a(3);
    rep(i,3)cin >> a.at(i);
    sort(a.begin(),a.end());
    if(a.at(0)%2==0||a.at(1)%2==0||a.at(2)%2==0) cout << 0 << endl;
    else{
        cout << a.at(0)*a.at(1) << endl;
    }    
}


Measured memory_bytes: 3608
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
   string s,ss;
   cin>>s>>ss;
   int mx=0;
   for(int i=0; i<=s.size()-ss.size(); i++){
        int k=i,c=0;
    for(int j=0; j<ss.size(); j++){
       if(ss[j]==s[k++]) c++;
    }
    mx=max(mx,c);
   }
   cout<<ss.size()-mx<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/




Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}


signed main(){
  int m,d;cin>>m>>d;
  int ans = 0;
  repd(i,1,m+1){
    repd(j,1,d+1){
      int d1 = j % 10, d2 = j/10;
      if(j >= 10 && d1 >= 2 && d2 >= 2 && d1*d2 == i)ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 1010
ll x[N], y[N], r[N], n;
double dist[N];

int main(){
	cin>>x[0]>>y[0]>>x[1]>>y[1]>>n;
	x[n+1] = x[1];
	y[n+1] = y[1];
	rep(i, n) cin>>x[i+1]>>y[i+1]>>r[i+1];
	fill(dist, dist+N, 1e100);
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 0));
	while(!q.empty()){
		P p = q.top(); q.pop();
		if(p.fst>dist[p.snd]) continue;
		rep(i, n+2){
			ll dx = x[i]-x[p.snd], dy = y[i]-y[p.snd], rr = r[i]+r[p.snd];
			double d = max(0.0, sqrt(dx*dx+dy*dy)-rr);
			if(p.fst+d+EPS<dist[i]){
				dist[i] = p.fst+d;
				q.push(P(dist[i], i));
			}
		}
	}
	cout.precision(9);
	cout<<fixed<<dist[n+1]<<endl;
	return 0;
}


Measured memory_bytes: 6128
fun main(args: Array<String>) {
    val a = readLine()!!.toString()
    val day = arrayOf("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT")
    if(a == day[0]) {
        println("7")
    } else if(a == day[1]) {
        println("6")
    } else if(a == day[2]) {
        println("5")
    } else if(a == day[3]) {
        println("4")
    } else if(a == day[4]) {
        println("3")
    } else if(a == day[5]) {
        println("2")
    } else if(a == day[6]) {
        println("1")
    }
}

Measured memory_bytes: 33732
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int h,n;
    cin >> h >> n;
    int a[n];
    int sum = 0;
    for(int i=0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    if (h <= sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B,M;
    cin>>A>>B>>M;
    vector<int>a(A);
    vector<int>b(B);
    vector<vector<int>>m(M+100,vector<int>(100));
    for(int i=0;i<A;i++){cin>>a.at(i);}
    for(int i=0;i<B;i++){cin>>b.at(i);}
    for(int i=0; i<M;i++){
      cin>>m.at(i).at(0)>>m.at(i).at(1)>>m.at(i).at(2);
    }
    int cos=a.at(m.at(0).at(0)-1)+b.at(m.at(0).at(1)-1)-m.at(0).at(2);
    for(int i=0; i<M;i++){
      int p=a.at(m.at(i).at(0)-1)+b.at(m.at(i).at(1)-1)-m.at(i).at(2);
      if(cos>=p){cos=p;}
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(a.at(0)+b.at(0)<cos){cout<<a.at(0)+b.at(0)<<endl;}
    else{cout<<cos<<endl;}
    return 0;
}

Measured memory_bytes: 44032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const ll mod=1000000007;
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
inline ll powmod(ll x, ll y) {ll res=1; for(ll i=0;i<y;i++){ res=res*x%mod; } return res;}
using namespace std;

signed main(void) {
    string s;
    cin >> s;
    (s[s.size() - 1] == 's')? cout << s + "es" : cout << s + "s";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int64_t N, M;
	cin >> N >> M;

	int64_t DIVIDER = 1000000007;
	int64_t res = 1;
	for (int32_t i = 1; i <= N; i++) {
		res *= i;
		res %= DIVIDER;
	}
	for (int32_t i = 1; i <= M; i++) {
		res *= i;
		res %= DIVIDER;
	}

	if (N == M) {
		res *= 2;
		res %= DIVIDER;
	} else if (N + 1 == M || N == M + 1) {
	} else {
		res = 0;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int x;
    int n;
    int min=100;
    int ans;
    bool is_ok;
    cin >> x >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=0; i<=110; i++){
        is_ok=true;
        for(int j=0; j<n; j++){
            if(i==p[j]){
                is_ok=false;
                break;
            }
        }
        if(is_ok==true){
            if(min>abs(i-x)){
                min=abs(i-x);
                ans=i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int i, j, k;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int a[][] = new int [n][m];
        int b[][] = new int [m][l];
        long  c[][] = new long[n][l];
        
        for(i = 0; i < n; i++){
            for(j = 0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        for(j = 0; j < m; j++){
            for(k = 0; k < l; k++){
                b[j][k] = sc.nextInt();
            }
        }
        
        for(i = 0; i < n; i++){
            for(j = 0; j < m; j++){
                for(k = 0; k < l; k++){
                    c[i][k] += a[i][j] * b[j][k];
                }
            }
        }
        for(i = 0; i < n; i++){
            for(k = 0; k < l; k++){
                System.out.printf("%d", c[i][k]);
                if(k == l - 1) break;
                System.out.printf(" ");
            }
            System.out.println();
        }
        sc.close();
    }
}



Measured memory_bytes: 82008
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {

ll a,b,c,d;
  ci(a>>b>>c>>d);
  co(b-a+1-b/c+(a-1)/c-b/d+(a-1)/d+b/lcm(c,d)-(a-1)/lcm(c,d))
}


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

int main() {
	int N; cin >> N;
	vector<tuple<string, int, int>> a;
	for (int i = 0; i < N; i++)
	{
		string s; int p;
		cin >> s >> p;
		a.push_back(make_tuple(s, p * -1, i));
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < N; i++)
	{
		int n; tie(ignore, ignore, n) = a.at(i);
		cout << n+1 << endl;
	}
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int r[200001]={0},d[200001]={0};
vector<pair<int,int>> A[200001];
int search(int x){
  r[x]=1;
  for(auto i:A[x]) if(!r[i.first]){
      if(i.second%2) d[i.first]=(d[x]+1)%2;
      else d[i.first]=d[x];
      search(i.first);
  }
}
int main(){
    int n,u,v,w;
    cin>>n;
    rep(i,n) cin>>u>>v>>w,A[u].push_back(make_pair(v,w)),A[v].push_back(make_pair(u,w));
    search(1);
    rep(i,n) cout<<d[i+1]<<endl;
}

Measured memory_bytes: 11008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};
 
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
 
const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;
 
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
 
ll ans[200002]	= {};
bool used[200002] = {};
vector<ll> g[200002];
 
void rec(int v, ll sum) {
	used[v] = true;
	ans[v] += sum;
	for (int i = 0; i < g[v].size(); i++) {
		if (!used[g[v][i]]) {
			rec(g[v][i], ans[v]);
		}
	}
}
 
int main() {
	IOS();
	ll n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		ll p, x;
		cin >> p >> x;
		ans[p] += x;
	}
	rec(1, 0);
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << (i == n ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 24448
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
ll n , s;
ll gett(ll b)
{
        ll k = n;
        ll ret = 0;
        while(k)
        {
                ret += k%b;
                k = k / b;
        }
        return ret;
}
int main()
{
        cin >> n >> s;
        if(s > n) {
                cout << -1 << endl; return 0;
        }
        if(s == n) {
                cout << n+1 << endl; return 0;
        }
        /*if(s == 1) {
                cout << n << endl; return 0;
        }*/
        for(ll i = 2 ; i <= 1000000;i++)
        {
                if(gett(i) == s) {
                        cout << i << endl; return 0;
                }
        }
        vector<ll> divs;
        for(ll i = 1 ; i*i <= (n-s) ;i++)
        {
                ll K = n - s;
                if(K%i == 0) {
                        if(K == i*i) {
                                divs.pb(i);
                        }else {
                                divs.pb(i);
                                divs.pb(K/i);
                        }
                }
        }
        sort(divs.begin() , divs.end());
        for(auto i : divs) {
                if(gett(i+1) == s) {
                        cout << i + 1 << endl; return 0;
                }
        }
        cout << "-1\n";
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n, k, s;
    cin >> n >> k >> s;
    i64 t = s + 1;
    if (t >= 1e8) t = 1;
    for (int i = 0; i < n; ++i) {
        if (i < k) cout << s << ' ';
        else cout << t << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280