akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  vector<ll> x(N), l(N);
  vector<pair<ll,ll>> se(N);
  FOR(i,N){ 
    cin >> x[i] >> l[i]; 
    se[i].se = x[i]-l[i];//最初
    se[i].fi = x[i]+l[i];//最後
  }
  sort(se.begin(),se.end());//終了時刻でソート。
  
  //main
  ll tmp = 0;
  ll ans = 1;
  for(int i=0; i<N; i++){
    if(se[tmp].fi > se[i].se){
      continue;
    }else{
      tmp = i;
      ans ++;
      //cout << i << endl;
    }
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
using namespace std;
int main(void) {
	int N, K;
	string S;
	
	cin >> N >> K;
	cin >> S;
	
	switch (S.at(K-1)) {
	case 'A':S.at(K-1) = 'a'; break;
	case 'B':S.at(K-1) = 'b'; break;
	case 'C':S.at(K-1) = 'c'; break;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string s;
cin>>s;

int cnt=0;
int swc=0;
int ans=0;
for(int i=0;i<s.length();i++){
    if(s[i]=='A'){
        swc=1;
    }
    if(swc==1){
        cnt+=1;
        if(s[i]=='Z'){
            ans=cnt;
        }
    }
}

cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  ll q = Q * 8;
  ll h = H * 4;
  ll s = S * 2;
  ll d = D;
  ll c2 = kMod * 100;
  c2 = min(q, c2);
  c2 = min(h, c2);
  c2 = min(s, c2);
  c2 = min(d, c2);

  if (N % 2 == 0) {
    cout << c2 * N / 2 << endl;
    return 0;
  }

  ll c1 = kMod * 100;
  c1 = min(q / 2, c1);
  c1 = min(h / 2, c1);
  c1 = min(s / 2, c1);

  ll ans = c2 * (N / 2);
  cout << ans + c1 << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n int
	fmt.Scan(&n)
	values := ScanNums(n)
	sort.Ints(values)
	curValue := float64(values[0])
	for i := 1; i < len(values); i++ {
		curValue = (curValue + float64(values[i])) / 2
	}
	fmt.Println(curValue)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
 ll s = 0;
 string n;
 cin >> n;
 for(int i = 0; i < SZ(n); i++){
     s += n[i] - '0';
 }
 if(s % 9 == 0) cout << "Yes" << endl;
 else cout << "No" << endl;

}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


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

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string ss, search;
  cin >> ss >> search;
  ss += ss;

  if(ss.find(search) != -1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N), SortA(N);
    rep(i, N) {
        cin >> A[i];
    }
    SortA = A;
    sort(SortA.begin(), SortA.end(), greater<int>());

    auto maxA = SortA[0];
    auto secondA = SortA[1];
    rep(i, N) {
        if (A[i] == maxA)
            cout << secondA << endl;
        else
            cout << maxA << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;

int main(){
  int h,w,ans=0;
  cin>>h>>w;
  int x[4]={1,-1,0,0};
  int y[4]={0,0,1,-1};
  vector<vector<char>> vec(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>vec[i][j];
  rep(i,h)rep(j,w){
    if(vec[i][j]=='#')continue;
    queue<pair<int,int>> q;
    if(!q.empty()){
      cout<<"eee"<<endl;
    }
    pair<int,int> p(i,j);
    vector<vector<int>> vvv(h,vector<int>(w,-1));
    q.push(p);
    vvv[i][j]=0;
    while(!q.empty()){
      p=q.front();
      q.pop();
      rep(k,4){
        int xx=p.first+x[k],yy=p.second+y[k];
        if(xx<0||xx>=h||yy<0||yy>=w||vec[xx][yy]=='#'||vvv[xx][yy]>-1) continue;
        //cout<<xx<<" "<<yy<<" "<<vec[xx][yy]<<" "<<vvv[xx][yy]<<endl;
          pair<int,int> pp(xx,yy);
          q.push(pp);
          vvv[xx][yy]=vvv[p.first][p.second]+1;
          ans=max(ans,vvv[xx][yy]);
      }
    }
    // rep(i,h){
    //   rep(j,w)cout<<vvv[i][j];
    //   cout<<endl;
    // }
    // cout<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
fun main(args : Array<String>) {
    val ss = readLine()!!

    var bCnt = 0
    var cnt = 0L

    for (i in ss.indices) {
        if (ss[i] == 'B') {
            bCnt++
        } else {
            cnt += bCnt
        }
    }

    println(cnt)
}


Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    string s, t;
    cin >> s >> t;

    cout << ((t.substr(0, s.size()) == s) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <stack>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	// abcd 0123   4 - 3 
	int cnt = 999999;
	for (int i = 0; i < s.size() - 2; i++) {
		int ans1 = ((s[i] - '0') * 100) + ((s[i + 1] - '0') * 10) + (s[i + 2] - '0');
		cnt = min(cnt, abs(753 - ans1));
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 256
def func(A):
  result = 0
  min = 0
  for a in A:
    if a < min:
      result += min - a
    else:
      min = a
  return result

if __name__ == "__main__":
    N = int(input())
    A = list(map(int,input().split()))
    print(func(A))

Measured memory_bytes: 32116
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    float T,X;
    float asn;
    cin >> T >> X;
    asn = T/X;
    cout << asn <<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		long n =sc.nextLong();
		long hold = (n*(n-1))/2;
		System.out.println(hold);
		out.close();
	}
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static class pair{
		int ai;
		int bi;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bi-o2.bi;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int n, R, ans;
string s;
signed main(){
	ios::sync_with_stdio(0); cin.tie(NULL);
	cin >> n >> s;
	for(int i = 0; i < n; ++i){
		if(s[i] == 'R') ++R;
	}
	ans = R;
	for(int i = 0; i < R; ++i){
		if(s[i] == 'R') --ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,x[100]={},y[100]={},h[100]={},a,j,b;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]) {
      a=i;
    }
  }
  for(int X=0; X<=100; X++) {
    for(int Y=0; Y<=100; Y++) {
      int H=h[a]+abs(X-x[a])+abs(Y-y[a]);
      b=1;
      for(int j=0; j<n; j++) {
        if(h[j]!=max(H-abs(X-x[j])-abs(Y-y[j]),0)) {
          b=0;
        }
      }
      if(b) {
        cout << X << " " << Y << " " << H << endl;
        return 0;
      }
    }
  }
}

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

int main(){
    int a[4];
    int b[4];

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];

    for(int i=1; i<=3; i++){
        a[0] += a[i];
        b[0] += b[i];
    }

    if(a[0] > b[0]){
        cout << a[0] << endl;
    }else{
        cout << b[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long[] d = new long[n];
			for (int i = 0; i < n; i++) {
				d[i] = cin.Long();
			}

			var dd = d.ToList();
			dd.Sort();
			long ans = dd[(int)(n / 2)] - dd[(int)(n / 2) - 1];

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 22240
#include <iostream>
//C++言語の票順ライブラリ　入出力を扱う
#include <algorithm>
//C++言語の標準ライブラリ　アルゴリズムを扱う
using namespace std;
/*これがないと
std::cin
あれば
cin
*/
static const int MAX = 200000;
int main(void)
{
	int R[MAX],n;
	
	cin >> n;
	//printf("%d",&n);
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv = max(maxv,R[i]-minv);
		minv = min(minv,R[i]);
	}
	cout << maxv << endl;
	
	return 0;
}
//コンパイル　g++ -o
		


Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
ll a[101010],b[101010],ans;
pair<ll,int> x[101010];
int n;
int main(){
	cin>>n;
	fo(i,0,n){
		cin>>a[i]>>b[i];
		x[i]=mp(a[i]+b[i],i);
	}
	sort(x,x+n);
	fo(i,0,n){
		if(i%2==0)ans+=a[x[n-i-1].se];
		else ans-=b[x[n-i-1].se];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
char c[55][55];


int main(){
  int h,w;
  string kari;
  cin >> h >> w;
  for(int i = 1;i <= h; i++){
    for(int j = 1;j <=w; j++){
      cin >> c[i][j];
    }
  }
  bool checked_true = true;
  for(int i = 1;i <=h;i++){
    for(int j = 1;j <=w;j++){
      if(c[i][j] == '#'&& c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#'){
        checked_true = false;
      }
    }
  }
  if(checked_true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys


def resolve():
    for line in sys.stdin:
        h, w = map(int, line.split())

        if h == w == 0:
            return

        for i in range(h):
            if i == 0 or i == h - 1:
                for j in range(w):
                    print("#", end="")
            else:
                for j in range(w):
                    if j == 0 or j == w - 1:
                        print('#', end="")
                    else:
                        print('.', end="")
            print()
        print()



resolve()



Measured memory_bytes: 7012
#include<stdio.h>
#include<string.h>

int main( void ) 
{
	char cards[201];
	char shuffle[201];
	int m,h;
	int len;

    
	while( 1 ) {
		scanf( "%s", cards );
		if( '-' == cards[0] ) { break; }
		len=strlen( cards );
		
		scanf( "%d", &m );
		while( 0<m-- ) {
			scanf( "%d", &h );
			memmove( shuffle, cards, h ); 
			shuffle[h] = '\0';
			memmove( cards, cards+h, len-h ); 
			cards[len] = '\0';
			memmove( cards+len-h, shuffle, h ); 
			cards[len] = '\0';
		}
		printf( "%s\n", cards);	
	}

	return 0;
}

Measured memory_bytes: 616
import java.io.*;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        class Node {
            int row;
            int col;
            int blackCount;
            Node(int row, int col, int blackCount) {
                this.row = row;
                this.col = col;
                this.blackCount = blackCount;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt();
            int n = in.nextInt();
            char[][] grid = new char[m][n];
            for (int i = 0; i < m; i++) {
                grid[i] = in.next().toCharArray();
            }

//            LinkedList<Node> queue = new LinkedList<>();
//            queue.add(new Node(0, 0, grid[0][0] == '#' ? 1 : 0));



            // 求所有路径中最少的"#"个数
            int[][] dp = new int[m][n];
            dp[0][0] = grid[0][0] == '#' ? 1 : 0;
            for (int j = 1; j < n; j++) {
                dp[0][j] = grid[0][j] == '#' && grid[0][j-1] == '.' ? dp[0][j-1] + 1 : dp[0][j-1];
            }

            for (int i = 1; i < m; i++) {
                dp[i][0] = grid[i][0] == '#' && grid[i-1][0] == '.' ? dp[i-1][0] + 1 : dp[i-1][0];
            }

            for (int i = 1; i < m; i++) {
                for (int j = 1; j < n; j++) {
                    dp[i][j] = Math.min(
                            dp[i-1][j] + (grid[i][j] == '#' && grid[i-1][j] == '.' ? 1 : 0),
                            dp[i][j-1] + (grid[i][j] == '#' && grid[i][j-1] == '.' ? 1 : 0)
                    );
                }
            }

            out.println(dp[m-1][n-1]);
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 23252
W, H, N = gets.split.map(&:to_i)
T = Array.new(N){gets.split.map(&:to_i)}

ox = 0
oy = 0
dx = W
dy = H

T.each do |x, y, a|
    case a
    when 1
        ox = x if x > ox
    when 2
        dx = x if x < dx
    when 3
        oy = y if y > oy
    when 4
        dy = y if y < dy
    end
end

x = [dx-ox, 0].max
y = [dy-oy, 0].max
puts x*y

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

public class Main {

	public static void main(String[] args) {
		
		String CMD = null ;
		BufferedReader BR = null;
		BR = new BufferedReader(new InputStreamReader(System.in));
		try {CMD = BR.readLine();
		} 
		catch (IOException e) {e.printStackTrace();
		}
		String[] str = CMD.split(" "); 
		
		int x = Integer.parseInt(str[0]);
		int y = Integer.parseInt(str[1]);
		
		if(x==y){
			System.out.println("a == b");
		}if(x<y){
			System.out.println("a < b");
		}if(x>y){
			System.out.println("a > b");
		}

	}

}

Measured memory_bytes: 24144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	long long p = 37;
	long long k = p + 1;
	cout << k * p + 1 << " " << k << endl;
	for (long long i = 1; i <= k; ++i) {
		cout << i << " ";
	}
	cout << endl;
	for (long long i = 0; i < p; ++i) {
		cout << 1;
		REP(q, p) {
			cout << " " << k + 1 + i * p + q;
		}
		cout << endl;
	}
	for (long long d = 0; d < p; ++d) {
		for (long long s = 0; s < p; ++s) {
			cout << 2 + d;
			for (long long t = 0; t < p; ++t) {
				cout << " " << k + 1 + t * p + (d * t + s) % p;
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 512
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int m,d,cnt;

int main()
{Tie
	cin>>m>>d;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
			if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
				cnt++;
	cout<<cnt<<'\n';
}

Measured memory_bytes: 256
def combi(n):
    if len(n) > 1:
        a = n.pop()
        for i in combi(n):
            yield i + [a]
            yield i + ['+', a]
    else:
        yield n

s = 0
for i in combi(list(input())):
    s += eval(''.join(i))

print(s)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int D, G;
	cin >> D >> G;
	vector<int> p(D),c(D);
	for(int i=0;i<D;i++){
		cin >> p[i] >> c[i];
	}
	int ans = 10000000;
	for(int s = 0;s < (1 << D);s++){
		int SUM = 0, NUM = 0, rest_i = -1;
		for(int i=0;i<D;i++){
			if(s >> i & 1){
				SUM += p[i] * (i + 1) * 100 + c[i];
				NUM += p[i];
			}
			else{
				rest_i = i;
			}
		}
		if(SUM < G){
			int need = (G - SUM) / (100 * (rest_i + 1));
			if ((G - SUM) % (100 * (rest_i + 1)) > 0) need++;
			if(need < p[rest_i]) NUM += need;
			else NUM = 10000000;
		}
		ans = min(NUM,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], k = tmp[1];
    string s = rdStr;

    auto g = s.group.array;
    long result;
    long[] que;
    long total;
    long cnt;
    foreach (x, y; g.zip)
    {
        if (x == '0')
        {
            if (que.length >= k)
            {
                result = max(result, total);
                total -= que[0];
                que.popFront;
            }
            que ~= y.to!long + cnt;
        }
        else cnt = y.to!long;
        total += y.to!long;
    }
    result = max(result, total);

    result.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4220
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int x=0 ,y=0;
      int[][] z;
      Scanner scanner = new Scanner(System.in);
      x = scanner.nextInt();
      y = scanner.nextInt();
      scanner.close();
      int sum = 3*x+y;
      System.out.println((int)(sum/2));

   }
}


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

using namespace std;

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


int main(){
 long n;
   cin >> n;
  
  map<string,long> mp;
  
 rep(i,n){
  string s;
   cin >> s;
   sort(s.begin(),s.end());
   mp[s]++;
 }
  
  long res=0;
  for(auto v:mp){
   res+=v.second*(v.second-1)/2;
  
  }
 
  cout << res << endl;
 
  }

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    int n;
    cin >> n;
    ll ans = 0;
    ll maxh = 0;
    for (ll i=0;i<n;i++){
        int h;
        cin >> h;
        if(maxh <= h){
            ans++;
            maxh = h;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=65;
const double eps=1e-9;
int n,k;
double x[N],y[N],c[N],r[N];
double dis(pair<double,double> a,pair<double,double> b) {
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
vector<pair<double,double> > cal(double x1,double y1,double r1,double x2,double y2,double r2) {//两圆交点
    x1-=x2,y1-=y2;
    double S=x1*x1+y1*y1,a=(S+r2*r2-r1*r1)/2,D=S*r2*r2-a*a;
    if(S==0)return {};
    if(D<0) return {};
    double A1=a*x1,B1=y1*sqrt(D);
    double A2=a*y1,B2=x1*sqrt(D);
    return {{(A1+B1)/S+x2,(A2-B2)/S+y2},{(A1-B1)/S+x2,(A2+B2)/S+y2}};
}
bool check(double t) {
    for(int i=0;i<n;i++) r[i]=t/c[i];
    vector<pair<double,double> > vec;
    for(int i=0;i<n;i++) {
    	vec.push_back({x[i],y[i]});
        for(int j=i+1;j<n;j++) {
            auto v=cal(x[i],y[i],r[i],x[j],y[j],r[j]);
            for(auto it:v) vec.push_back(it);
        }
    }
    for(auto it:vec) {
        int cnt=0;
        for(int i=0;i<n;i++) {
            if(r[i]+eps>=dis(it,{x[i],y[i]})) cnt++;
        }
        if(cnt>=k) return true;
    }
    return false;
}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) {
        scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
    }
    double L=0,R=1000010;
    for(int i=0;i<100;i++) {
        double mid=(L+R)/2;
        if(check(mid)) R=mid;
        else L=mid;
    }
    printf("%.6lf\n",R);
    return 0;
}

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

int n, ai;

int main(){
	scanf("%d", &n);
	
	long long res = 0, sum = 0;
	
	map <long long, int> cnt;
	cnt[0]++;
	
	for(int i = 0; i < n; i++){
		scanf("%d", &ai);
		sum += ai;
		res += cnt[sum];
		cnt[sum]++;
	}
	printf("%lld\n", res);
	
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]) {
	int N = 0;
	scanf("%d", &N);

	unsigned long long *L = (unsigned long long*)malloc((N+1)*sizeof(unsigned long long));
	memset(L, 0, (N+1) * sizeof(unsigned long long));

	L[0] = 2;
	L[1] = 1;

	for (int i = 2; i < N+1; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}

	printf("%lld", L[N]);
}

Measured memory_bytes: 128
N = int(input())
a = list(input())
b = list(input())
c = list(input())
count = 0
for i in range(N):
    if a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        if a[i]==b[i] and b[i]==c[i]:
            continue
        else:
            count += 1
    else:
        count += 2
print(count)

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

void solve(long long L, long long R, long long d) {
    ll ans = 0;
    for (ll i = L; i <= R; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long L;
    scanf("%lld", &L);
    long long R;
    scanf("%lld", &R);
    long long d;
    scanf("%lld", &d);
    solve(L, R, d);
    return 0;
}


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

int main() {
  int p, q, r;
  cin >> p >> q >> r;
  
  int a, b, c;
  a = p + q;
  b = q + r;
  c = r + p;
  
  int min;
  min = a;
  
  if (b < min) min = b;
  if (c < min) min = c;
  
  cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int a, b, c;
	int min = a;
	int max = a;
	scanf("%d %d %d", &a, &b, &c);

	if(a<b) {
		if(c<a)
			printf("%d %d %d\n", c, a, b);
		else if(c<b)
			printf("%d %d %d\n", a, c, b);
		else
			printf("%d %d %d\n", a, b, c);
	}
	else if(b<a){
		if(c<b)
			printf("%d %d %d\n", c, b, a);
		else if(c<a)
			printf("%d %d %d\n", b, c, a);
		else
			printf("%d %d %d\n", b, a, c);
	}

	return 0;
}


Measured memory_bytes: 2064
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include<type_traits>

using namespace std;
typedef pair<int, int> Edge;
vector<Edge> G[10];

int main() {
	string a, b, c,d;
	cin >> a >> b >> c;
	d = 'A';
	d += b[0];
	d += 'C';
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

void solve(){
   ll a[5];
   ll ans=0;
   loop(i,0,5){
       cin >> a[i];
       if(a[i]==0) ans=i+1;
   }
    cout << ans << endl;
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int D;
  cin >> D;
  vector<int> c(26);
  REP(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  REP(i, D) REP(j, 26) cin >> s[i][j];

  vector<int> t(D);
  REP(i, D) cin >> t[i];
  REP(i, D) t[i]--;

  int ans = 0;
  vector<int> last(26);
  REP(i, D) {
    ans += s[i][t[i]];
    last[t[i]] = i + 1;
    REP(j, 26) ans -= c[j] * (i + 1 - last[j]);
    cout << ans << "\n";
  }
}

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

int main(){
    int N;
    int T, X, Y;
    int disT, disXY;
    int curT = 0;
    int curX = 0;
    int curY = 0;
    bool ans = true;
    
    cin >> N;
    for(int i=0; i<N; i++){

        cin >> T >> X >> Y;
        disT = T-curT;
        disXY = abs(X-curX) + abs(Y-curY);

        if(disT<disXY || disT%2 != disXY%2){
            ans = false;
        }else{
            curT = T;
            curX = X;
            curY = Y;
        }
    }

    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int t1,t2;
    ll a1,a2,b1,b2;
    ll da1,da2,db1,db2,d1,d2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    da1=a1*t1;da2=a2*t2;
    db1=b1*t1;db2=b2*t2;
    d1=da1-db1;d2=da2-db2;
    ll ans=0;
    if (d1<0){
        if (d2+d1==0){
            printf("infinity");
            return 0;
        }else if (d1+d2<0){
            cout<<0;
            return 0;
        }else{
            if (-d1%(d2+d1)==0){
                ans+=2*-d1/(d2+d1);
            }else {
                ans+=2*(-d1/(d2+d1));
                ans++;
            }
        }
        
    }else {
        d1*=-1;
        d2*=-1;
        if (d2+d1==0){
            printf("infinity");
            return 0;
        }else if (d1+d2<0){
            cout<<0;
            return 0;
        }else{
            if (-d1%(d2+d1)==0){
                ans+=2*-d1/(d2+d1);
            }else {
                ans+=2*(-d1/(d2+d1));
                ans++;
            }
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int ans=0;
for (int i=1;i<=a;i++){
	int temp = i;
	int total = 0;
	while (temp>0){
		total += temp %10;
		temp /=10;
	}
	if (total >=b&& total <=c){
		ans +=i;
	}
}

printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 1700
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m,l=0,r=10000000000,h;
  cin >> n >> m;
  vector<ll> a(n),sum(n+1,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<ll>());
  for(int i=0;i<n;i++){
    sum[i+1] = sum[i] + a[i];
  }
  while(r-l>1){
    h = (r+l)/2;
    ll idx = 0,cnt=0;
    for(int i=n-1;i>=0;i--){
      while(idx!=n&&a[i]+a[idx]>=h){
        idx++;
      }
      cnt += idx;
    }
    if(cnt<m){
      r = h;
    }else{
      l = h;
    }
  }
  ll ans = 0,idx=0,cnt=0;
  for(int i=n-1;i>=0;i--){
    while(idx!=n&&a[i]+a[idx]>=l){
      idx++;
    }
    cnt += idx;
    ans += a[i]*idx + sum[idx];
  }
  while(m<cnt){
    cnt--;
    ans -= l;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private void solve() {
        // 入力処理
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Task> tasks = new ArrayList<Task>();
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            tasks.add(new Task(A, B));
        }

        // 締め切りの早い順に並び替える。ソートはラムダ式を使うのが便利。
        tasks.sort((a,b)-> a.deadLine - b.deadLine);
        //for (Task task : tasks) {
        //    System.out.println(task.timeToTake + " " + task.deadLine);
        //}

        // 判定処理
        long timeSum = 0;
        String ans = "Yes";
        for (Task task : tasks) {
            timeSum += task.timeToTake;
            if (timeSum > task.deadLine) {
                ans = "No";
                break;
            }
        }
        System.out.print(ans);
    }

    class Task {
        int timeToTake;
        int deadLine;
        Task (int timeToTake, int deadLine) {
            this.timeToTake = timeToTake;
            this.deadLine = deadLine;
        }
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 109980
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

struct edge{int first,second;};

int N,M;
bool vis[100010];
int  dis[100010];
vector<edge>G[100010];

bool dfs(int q){
  vis[q]=true;
  for(auto x:G[q]){
    if(vis[x.first]){
      if(dis[x.first]!=dis[q]+x.second)return false;
      continue;
    }else{
      dis[x.first]=dis[q]+x.second;
      if(!dfs(x.first))return false;
    }
  }
  return true;
}

signed main(){
  cin>>N>>M;
  for(int t=1;t<=M;t++){
    int l,r,d;cin>>l>>r>>d;
    G[l].push_back(edge{r,d});
    G[r].push_back(edge{l,-d});
  }

  for(int t=1;t<=N;t++){
    if(vis[t])continue;
    if(!dfs(t)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 15616
#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 m, f, r;
	cin >> m >> f >> r;
	while (!(m == -1 && f == -1 && r == -1))
	{
		if (m == -1 || f == -1)
			cout << 'F';
		else if (m + f >= 80)
			cout << 'A';
		else if (m + f >= 65)
			cout << 'B';
		else if (m + f >= 50)
			cout << 'C';
		else if (m + f >= 30)
		{
			if (r >= 50)
				cout << 'C';
			else
				cout << 'D';
		}
		else 
			cout << 'F';
		cout << endl;
		cin >> m >> f >> r;
	}
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

constexpr int msd(int x){
    while(x >= 10) x /= 10;
    return x;
}

constexpr int lsd(int x){
    return x % 10;
}

void solution()
{
    int n;
    cin >> n;
    vector<vector<int>> count(10, vector<int>(10));
    for(int i = 1; i <= n; ++i){
        count[lsd(i)][msd(i)] += 1;
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i){
        answer += count[msd(i)][lsd(i)];
    }
    cout << answer << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
const int maxn=10000;
using namespace std;
 bool sortbysec(pair<ll,ll> &a, pair<ll,ll> &b) { 
    return (a.second < b.second); 
} 
 
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
/* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif */
{ 
    
    int l,r,d;
    cin>>l>>r>>d;
    int nb=0;
    for(int i=l;i<=r;i++)
    {
    	if(i%d==0)nb++;
	}
	cout<<nb<<endl;
}



Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;
void solve() {
  long long N, D, x, y, ans = 0;
  cin >> N >> D;
  D *= D;
  rep(i, 0, N) {
    cin >> x >> y;
    ans += (D >= x * x + y * y);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <bitset>
#include <utility> 
using namespace std;

int main() {
    int N; cin >> N;
    string s; cin >> s;
    int red = count(s.cbegin(), s.cend(), 'R');
    int blue = N - red;
    if (red>blue) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, k = [ int(i) for i in input().split(' ') ]
xs = [ int(x) for x in input().split(' ') ]
i0 = xs.index(min(xs))
print(1 + min([ (i + k - 2) // (k - 1) + (n - i - 2) // (k - 1)
  for i in range(max(i0 - k + 1, 0), min(i0, n - k) + 1) ]))

Measured memory_bytes: 84764
#include <iostream>
#include <stack>
#include <map>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n)break;
		string s;
		cin>>s;
		stack<pair<int,int> > st;
		while(n--){
			int a,b;
			cin>>a>>b;
			if(a<b) st.push(make_pair(a-1,b-1));
			else st.push(make_pair(b-1,a-1));
		}
		while(!st.empty()){
			pair<int,int> sw=st.top();
			st.pop();
			char a=sw.first,b=sw.second;
			char tmp=s[a];
			s[a]=(s[b]-(a-b)-'a'+26*4)%26+'a';
			s[b]=(tmp-(a-b)-'a'+26*4)%26+'a';
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];


int main() {
    int n,ba = 0,b = 0,a = 0,ans = 0;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        for (int j = 0; j < s[i].size()-1; ++j) {
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') ba++;
        else if(s[i][0] == 'B') b++;
        else if(s[i][s[i].size()-1] == 'A') a++;
    }
    int mn = min(a,b),mx = max(a,b);
    if(ba == 0){
        ans += mn;
    }else{
        if(a+b == 0) ans += (ba-1);
        else {
            ans += ba+mn;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int a, b, t;
    cin >> a >> b >> t;

    cout << (t / a) * b << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
arr = []

for i in range(N):
  a = input()
  arr.append(a)
  
arr.sort()
arr.append("")

a = [[] for i in range(N+1)]
cnt = 0

for i in range(1,N+1):
  
  if arr[0] != arr[1] and i == 1:
    a[1].append(arr[0])
  
  if arr[i] == arr[i-1]:
    if cnt == 0:
      cnt += 1
    cnt += 1	
  else:
    if cnt > 1:
      a[cnt].append(arr[i-1])
      cnt = 1
    else:
      cnt = 1
      if arr[0] != arr[i-1]:
        a[1].append(arr[i-1])
for i in range(N):
  if a[N-i] == []:
    p = 0
  else:
    b = a[N-i]
    b.sort()
    for j in b:
      if j != "":
        print(j)
    break

Measured memory_bytes: 35016