akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, x, y = 0, z = 0, h, w, ans = 0, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;
  bool ok=true;
  cin >> s;
  if(s[s.size()-1] == '2' || s[s.size()-1] == '4' || s[s.size()-1] == '5' ||s[s.size()-1] == '7' ||s[s.size()-1] == '9')
    pri("hon");
  else if(s[s.size()-1] == '0' ||s[s.size()-1] == '1' ||s[s.size()-1] == '6' ||s[s.size()-1] == '8')
    pri("pon");
  else
    pri("bon");
  return 0;
}


Measured memory_bytes: 3624
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    
    sort(vec.begin(), vec.end());
    cout << vec[n / 2] - vec[n / 2 - 1] << endl;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  map<int64_t, int64_t> mp;
  for (int i = 0; i < N; i++)
  {
    int64_t a;
    cin >> a;
    mp[a]++;
  }
  for (int i = 0; i < M; i++)
  {
    int64_t b, c;
    cin >> b >> c;
    mp[c] += b;
  }
  priority_queue<pair<int64_t, int64_t>> pq;
  for (auto p : mp)
  {
    pq.push(p);
  }
  int64_t ans = 0, n = 0;
  while (n < N)
  {
    auto t = pq.top();
    pq.pop();
    if (n + t.second <= N)
    {
      n += t.second;
      ans += t.first * t.second;
    }
    else
    {
      ans += t.first * (N - n);
      n = N;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 19968
#include <iostream>

using namespace std;

int main()
{
   int a, b,c;
    cin >>a>>b>>c;
    if(a!=b && a!=c){
        cout<<a<<endl;
        }else if(b!=a&& b!=c){
            cout<<b<<endl;

        } else{

            cout<<c<<endl;
        }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
        String b = "Yes";
        int c = a.length();
        for(int i=0;i<(c-1)/2;i++){if(a.charAt(i) == a.charAt(c-1-i) && a.charAt(i) == a.charAt((c-1)/2-1-i)){ }
                                  else{b = "No";break;}
                                  }
		System.out.println(b);
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a < b)
	{
	printf("a < b\n");
	}
	else if(a == b)
	{
	printf("a == b\n");
	}
	else
	{
	printf("a > b\n");
	}
	return 0;
}


Measured memory_bytes: 1928
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	for(int i=0;i<2;i++){
		if(s.substr(i,1)==s.substr(i+1,1) &&s.substr(i+1,1)==s.substr(i+2,1) ){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
x = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for t in range(N):
    if x[t] == 'AC':
        AC += 1
    elif x[t] == 'WA':
        WA += 1
    elif x[t] == 'TLE':
        TLE += 1
    else:
        RE += 1
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)


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

int main(void){
  int n; cin >> n;
  int a[n],b[n];
  vector<P> p;
  rep(i,n){
    cin >> a[i] >> b[i];
    p.push_back(make_pair(b[i],a[i]));
  }
  sort(p.begin(),p.end());
  ll sumtime = 0;
  rep(i,n){
    sumtime += p.at(i).second;
    if(sumtime > p.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int m=0,now=0;
  string s;
  cin >> s;
  for (int i=0;i < s.size();i++){
    if (s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C'){
      now=0;
    }
    else{
      now++;
    }
    m=max(m,now);
  }
  cout << m << endl;
}
  

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

for i in range(N):
    city, point = input().split()
    point = int(point)
    s = (city, point, i+1)
    S.append(s)

S.sort(key=lambda x: x[1], reverse=True)

S.sort(key=lambda x: x[0])

for s in S:
    print(s[2])

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)	cin >> a.at(i);
  
  int c=0;
  for(int i=0;i<n;i++){
    if(i%2==0&&a.at(i)%2==1)	c++;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3596
W, H, N = map(int,input().split())
xmin,xmax,ymin,ymax = 0,W,0,H
for _ in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        if x > xmin:
            xmin = x
    elif a == 2:
        if x < xmax:
            xmax = x
    elif a == 3:
        if y > ymin:
            ymin = y
    else:
        if y < ymax:
            ymax = y

#ans = max(0,(xmax-xmin)*(ymax-ymin))
if xmax-xmin > 0 and ymax-ymin > 0:
    print((xmax-xmin)*(ymax-ymin))
else:
    print(0)

Measured memory_bytes: 3064
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0], is_prime[1] = False, False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]: ass.append(i)
    return ass

d = primes(10**5)
d2017 = []
for i in d:
    if i > 10**5: break
    if (i+1)//2 in d:
        d2017.append(i)

import bisect
q = int(input())
ans = 0
for _ in range(q):
    l, r = map(int, input().split())
    index_l = bisect.bisect_left(d2017, l-1)
    index_r = bisect.bisect_right(d2017, r)
    print(index_r-index_l)

Measured memory_bytes: 10308
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[m];
        int coutA = 0;
        int coutB = 0;
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt();
            if(a[i] < x){
                coutA++;
            } else {
                coutB++;
            }
        }
        System.out.println(Math.min(coutA, coutB));
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <cstdlib>
#include <map> // pair
#include <vector>
#include <list>
#include <algorithm>

using namespace std;
int A;
int B;

int main()
{
    scanf("%d%d\n",&A,&B);
    if (A%2==1 and B%2==1) printf("Yes");
    else printf("No" );
}


Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramD a = new ProgramD();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {

            string[] s = Console.ReadLine().Split(' ');

            Console.WriteLine((int.Parse(s[0]) - 1) * (int.Parse(s[1]) - 1));


        }
    }

    class ProgramB
    {
        public void main()
        {

            string s = Console.ReadLine();

            Console.WriteLine(s[0] + (s.Length - 2).ToString() +s[s.Length -1]);


        }
    }

    class ProgramC
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            int count4 = 0;
            int count2 = 0;

            for (int i = 0; i < n;i++)
            {
                if (long.Parse(a[i]) % 4 == 0)
                    count4++;
                else if(long.Parse(a[i]) % 2 == 0)
                    count2++;
            }


            if (count4 >= n / 2)
            {
                Console.WriteLine("Yes");
                return;
            }


            if (2 * count4 + count2 >= n)
            {
                Console.WriteLine("Yes");
                return;
            }
            

            Console.WriteLine("No");


        }
    }

    class ProgramD
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            List<int> array = new List<int>();
            int[,] ans = new int[int.Parse(s[0]), int.Parse(s[1])];

            for (int i = 0; i < n; i++)
                for (int j = 0; j < int.Parse(a[i]); j++)
                    array.Add(i + 1);

            int k = 0;
            for (int i = 0; i < int.Parse(s[0]); i++)
                for (int j = 0; j < int.Parse(s[1]); j++)
                {
                    if (i % 2 == 0)
                    {
                        ans[i, j] = array[k];
                    }
                    else
                    {
                        ans[i, int.Parse(s[1])- 1 -j] = array[k];
                    }

                    k++;
                }

            for (int i = 0; i < int.Parse(s[0]); i++)
                for (int j = 0; j < int.Parse(s[1]); j++)
                {
                    Console.Write(ans[i, j]);
                    if( j == int.Parse(s[1]) - 1)
                        Console.WriteLine("");
                    else
                        Console.Write(" ");


                }



        }
    }

}






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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

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

    string s,t="";
    Cin(s);
    ll size = Size(s);
    rep(i,size){
        if(s[i]=='0') t.push_back('0');
        else if(s[i]=='1') t.push_back('1');
        else{
            if(Size(t) != 0) t.pop_back();
        }
    }
    Cout(t);
    return 0;
}

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

int main(){
  int n, count=0;
  cin >> n;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      if(s[i]>=s[j]){
        if(j==i){
          count+=1;
        }
      }else{
        break;
      }
    }
  }
  cout << count << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 300005
using namespace std;
typedef long long ll;
int n;
ll a[N],b[N],s[N],db[35]={1},ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=30;i++)
        db[i]=db[i-1]*2;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int bit=0;bit<30;bit++){
        ll am=0,bm=0,res=0;
        for(int i=1;i<=n;i++){
            s[i]=b[i]%db[bit+1];
        }
        sort(s+1,s+1+n);
        for(int i=1;i<=n;i++){
            ll t=a[i]%db[bit+1];
            ll p1=s+1+n-lower_bound(s+1,s+1+n,db[bit]-t);
            ll p2=s+1+n-lower_bound(s+1,s+1+n,db[bit+1]-t);
            ll p3=s+1+n-lower_bound(s+1,s+1+n,db[bit+1]+db[bit]-t);
            res+=p1+p3-p2;
        }
        if(res%2)
            ans+=db[bit];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			int k=sc.nextInt();
			if(k==0) {
				System.out.println((long)n*n);
				return;
			}
			int res=0;
			long ans=0;
			for(int b=k+1;b<=n;b++) {
			res=n/b;
			ans+=res*(b-k);
			ans+=Math.max(n-(res*b+k-1), 0);
			}
			System.out.println(ans);
		}
	}



Measured memory_bytes: 21972
from collections import Counter
n = int(input())
v = [int(x) for x in input().split()]

v_odd = [v[x] for x in range(n) if x % 2 != 0]
v_eve = [v[x] for x in range(n) if x % 2 == 0]

odd_c = Counter(v_odd).most_common() + [(0,0)]
eve_c = Counter(v_eve).most_common() + [(0,0)]

if odd_c[0][0] != eve_c[0][0]:
    print(n - odd_c[0][1] - eve_c[0][1])
else:
    print(n - max(odd_c[1][1] + eve_c[0][1], odd_c[0][1] + eve_c[1][1]))

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

int main(){
  int n; cin >> n;
  int k[n];
  vector<int> m;
  priority_queue<int> que;
  for(int i=0; i<n; i++){
    cin >> k[i];
    que.push(k[i]);
  }
    
  for(int i=0; i<n; i++){
    int a = que.top();
    if(k[i]==a){
      que.pop();
      cout << que.top() << endl;
      que.push(a);
    }else{
      cout << que.top() << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3316
f=lambda:map(int,input().split())
n,m=f()
l=[]
for _ in range(n):
  l+=[tuple(f())]
l.sort()
c=0
for a,b in l:
  if b<m:
    m-=b
    c+=a*b
  else:
    c+=a*m
    break
print(c)

Measured memory_bytes: 16988
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		
		val a,b = sc.nextInt()	
		val t = new TwoInt(a,b)
		
		println(f"${t.d}%d ${t.r}%d ${t.f}%f")
	}
	
}

class TwoInt(val a : Int, val b: Int){
	val d = a/b
	val r = a%b
	val f = a.asInstanceOf[Double]/b.asInstanceOf[Double]
}

Measured memory_bytes: 45220
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;

class Main {

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

	void run() {
		Scanner sc = new Scanner();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long d = sc.nextLong();
		if (d == 0) {
			System.out.printf("%.20f", (m - 1) * 1. / n);
			return;
		}
		if (n - d < 0) {
			System.out.println(0);
			return;
		}
		double ans = (m - 1) * 1. * 2 * (n - d) / n / n;
		System.out.printf("%.20f", ans);
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21204
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
S, T = input().split()

answer = ''
for i in range(N):
    answer += S[i]
    answer += T[i]

print(answer)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC171
{
    class A
    {
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var a = Console.ReadLine();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();

            if(Char.IsUpper(a[0])) Console.WriteLine("A");
            else Console.WriteLine("a");

            
        }
    }
}


Measured memory_bytes: 25796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
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() {
  ll k,x;
  cin >> k >> x;
  
  for(ll i=x-(k-1); i<x; i++)
    cout << i << " ";
  for(ll i=x; i<x+k; i++)
    cout << i << " ";
  cout << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#define SIZE 5005
#define INF 1000000000000000LL

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

vector <int> vec[SIZE];
int dp1[SIZE],nd[SIZE];
ll dp2[SIZE][SIZE];
ll cur[SIZE];
ll A[SIZE];

void dfs(int v=0,int p=-1)
{
	nd[v]=1;
	dp2[v][0]=A[v];
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i];
		if(to!=p)
		{
			dfs(to,v);
			if(A[v]>0)
			{
				int pl=SIZE;
				if(A[to]>0) pl=min(pl,dp1[to]);
				for(int j=0;j<nd[to];j++) if(dp2[to][j]<0) pl=min(pl,j+1);
				dp1[v]+=pl;
			}
			for(int j=0;j<nd[v]+nd[to];j++) cur[j]=INF;
			for(int j=0;j<nd[v];j++)
			{
				for(int k=0;k<nd[to];k++)
				{
					cur[j+k]=min(cur[j+k],dp2[v][j]+dp2[to][k]);
					if(dp2[to][k]<0) cur[j+k+1]=min(cur[j+k+1],dp2[v][j]);
				}
				if(A[to]>0)
				{
					cur[j+dp1[to]+1]=min(cur[j+dp1[to]+1],dp2[v][j]);
				}
			}
			nd[v]+=nd[to];
			for(int j=0;j<nd[v];j++) dp2[v][j]=cur[j];
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs();
	int ret=SIZE;
	if(A[0]>0) ret=dp1[0];
	for(int i=0;i<SIZE;i++) if(dp2[0][i]<0) ret=min(ret,i);
	printf("%d\n",ret);
	return 0;
}


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

int main(){
	ll n,k; cin >> n >> k;
	string s; cin >> s;
	if(s[k-1] == 'A')s[k-1] = 'a';
	else if(s[k-1] == 'B')s[k-1] = 'b';
	else s[k-1] = 'c';
	cout << s << endl;
}

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

int main(){
  int N;
  cin >> N;
  int x;
  
  x = N % 100;
  x = x % 10;
  
  if(x == 3){
    cout << "bon" << endl;
  }else if (x == 0 || x == 1 || x == 6 || x == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  
  return 0;
}
  
  

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;



int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c)puts("Yes");
    else if(a == c && a != b)puts("Yes");
    else if (b == c && a != b)puts("Yes");
    else puts("No");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007




int main() {

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

	if (a == 0) {
		if (b == 100)cout << b + 1 << endl;
		else cout << b << endl;
	}
	else if (a == 1) {
		if (b == 100)cout << b * 100 + 100 << endl;
		else cout << b * 100 << endl;
	}
	else {
		if (b == 100)cout << b * 10000 + 10000 << endl;
		else cout << b * 10000 << endl;
	}



	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Data {
    ll K;
    ll L;
    ll R;
};

ll solve() {
    ll N;
    cin >> N;
    vector<Data> F, S, A;
    REP(i, N) {
        Data d;
        cin >> d.K >> d.L >> d.R;
        if (d.L == d.R)
            A.push_back(d);
        else if (d.L < d.R)
            S.push_back(d);
        else
            F.push_back(d);
    }
    sort(F.begin(), F.end(), [](Data a, Data b) {
        if (a.K == b.K)
            return abs(a.L - a.R) > abs(b.L - b.R);
        return a.K > b.K;
    });
    sort(S.begin(), S.end(), [](Data a, Data b) {
        if (a.K == b.K)
            return abs(a.L - a.R) > abs(b.L - b.R);
        return a.K < b.K;
    });
    ll ret = 0;
    REP(i, A.size()) {
        ret += A[i].L;
    }
    {
        priority_queue<Data, vector<Data>, function<bool(Data, Data)>> q([](Data a, Data b) {
            return abs(a.L - a.R) < abs(b.L - b.R);
        });

        ll index = F.size();
        ll fi = 0;
        while (index > 0) {
            while (fi < F.size() && F[fi].K >= index) {
                q.push(F[fi++]);
            }
            index--;
            if (q.empty())
                continue;
            ret += q.top().L;
            q.pop();
        }

        while (!q.empty()) {
            ret += q.top().R;
            q.pop();
        }
    }
    {
        priority_queue<Data, vector<Data>, function<bool(Data, Data)>> q([](Data a, Data b) {
            return abs(a.L - a.R) < abs(b.L - b.R);
        });

        ll index = F.size() + A.size() + 1;
        ll si = 0;
        while (index <= N) {
            while (si < S.size() && S[si].K < index) {
                q.push(S[si++]);
            }
            index++;
            if (q.empty())
                continue;
            ret += q.top().R;
            q.pop();
        }

        while (si < S.size()) {
            ret += S[si++].L;
        }
        while (!q.empty()) {
            ret += q.top().L;
            q.pop();
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    REP(_, Q) {
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 12664
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    vector<int> num(4);
    rep(i, 4) {
        num[i] = s[i] - '0';
    }
    rep(i, 1<<3) {
        int sum = num[0];
        string ans = "";
        ans += (char)(num[0] + '0');
        rep(j, 3) {
            if ((i>>j) & 1) {
                sum += num[j+1];
                ans += '+';
                ans += (char)(num[j+1] + '0');
            }
            else {
                sum -= num[j+1];
                ans += '-';
                ans += (char)(num[j+1] + '0');
            }
        }
        if (sum == 7) {
            for (auto aa: ans) {
                cout << aa;
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    int ACcount=0,WAcount=0,TLEcount=0,REcount=0;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="AC")
        ACcount++;
        else if(s=="WA")
        WAcount++;
        else if(s=="TLE")
        TLEcount++;
        else if(s=="RE")
        REcount++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<ACcount<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<WAcount<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<TLEcount<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<REcount<<endl;

    return 0;
}


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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
  
   int t;
   cin>>t;
   unordered_map<string,int>nish;
   long long int total=0;
   for(int i=0;i<t;i++)
   {
    string temp;
    cin>>temp;
    if(nish[temp]==0)
    {
      nish[temp]=1;
      total++;
    }
   }

   cout<<total<<endl;
return 0;

}

Measured memory_bytes: 17580
#include <stdio.h>

int main(){
  int r, x, n, i = 0, j, reserve;
  int A[100000];

  scanf("%d", &n);
  for(j = 0; j < n; j++)
    scanf("%d", &A[j]);

  r = n-1;

  for(j = 0; j < r; j++){
    if(A[j] <= A[r]){
      reserve = A[j];
      A[j] = A[i];
      A[i] = reserve;
      i++;
    }
  }

  reserve = A[i];
  A[i] = A[r];
  A[r] = reserve;

  for(j = 0; j < n; j++){
    if(j == i)
      printf(" [%d]", A[j]);
    else if(j == 0)
      printf("%d", A[j]);
    else
      printf(" %d", A[j]);
  }
  printf("\n");

  return 0;

}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	vector<int> a;
	a.assign(n, 0);
	for (int i = 0; i < m; ++i) {
		int s, c; scanf("%d%d", &s, &c);
		if (n > 1 && s == 1 && c == 0) {
			puts("-1");
			return;
		}
		if (a[s-1] == 0 || a[s-1] == c) a[s-1] = c;
		else {
			puts("-1");
			return;
		}
	}
	if (n != 1 && a[0] == 0) a[0] = 1;
	for (int i = 0; i < n; ++i) {
		printf("%d", a[i]);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;

int a[1005];

int main(){
	int n, res = -1, res2 = 10000;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		res = max(res, a[i]);
		res2 = min(res2, a[i]);
	}
	cout << res - res2;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int n;
	int a[111];
	int i;
	
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	
	for(i=n-1;i>0;i--){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);
	
	return 0;
}

Measured memory_bytes: 596
let n=Int(readLine()!)!
let st=readLine()!.split(separator:" ")
let s=st[0]
let t=st[1]
let S=Array(s)
let T=Array(t)
var ans:[Character]=[]
for i in 0...n-1{
  ans.append(S[i])
  ans.append(T[i])
}
for a in ans{
  print(a,terminator:"")
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    vector<li> plus;
    vector<li> minus;
    li n;
    cin >> n;
    rin{
        li x, y;
        cin >> x >> y;
        plus.pb(x + y);
        minus.pb(x - y);
    }
    sort(allof(plus));
    sort(allof(minus));

    cout << max(plus.back() - plus.front(), minus.back() - minus.front()) << endl;


    return 0;
}


Measured memory_bytes: 6644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if((a-b)%2==0) {
			System.out.print("Alice");
		}
		else {
			System.out.print("Borys");
		}
	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0; i<(int) (x); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans=0, i=0;
	if(k<=a)
	{
		cout << k;
		return 0;
	}
	ans += a;
	k -= a;
	k -= b;
	if(k > 0)
		ans -= k;
	cout << ans;
	//////////////////////////////////
	//--------end--------
	//
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    if (a[0]==0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i,n) {
        if (a[i] <= 1000000000000000000/ans) ans *= a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4028
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  if((b-a)%2 ==0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7
pos = [1]+[0]*M
neg = [1]+[0]*M
n = 1
for i in range(1, M+1):
    n = n*i%mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)
ans = 0

def comb(n, r):
    return pos[n]*neg[r]*neg[n-r]%mod

# i個数字以上が被っている時の通り数
for i in range(N+1):
    ans += (-1)**i*comb(N, i)*pos[M]*neg[M-i]*(pow(pos[M-i]*neg[M-N], 2, mod))
    ans %= mod
print(ans)

Measured memory_bytes: 103980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int a[2][2010][2010];
int sum[2][2010][2010];
#define All(x) (sum[x][2 * k][2 * k])
inline int Get(int w, int x1, int y1, int x2, int y2) {
	if(x1 > x2 || y1 > y2) return 0;
	return sum[w][x2][y2] - sum[w][x2][y1 - 1] - sum[w][x1 - 1][y2] + sum[w][x1 - 1][y1 - 1];
}
int main() {
//	freopen("in.txt", "r", stdin);
	int n = read(), k = read();
	char s[10];
	rep(i, 1, n) {
		int x = read(), y = read();
		x = x % (2 * k) + 1;
		y = y % (2 * k) + 1;
	//	printf("%d %d\n", x, y);
		scanf("%s", s);
		if(s[0] == 'B') ++ a[0][x][y];
		else ++ a[1][x][y];
	}
	rep(w, 0, 1) {
		rep(i, 1, 2 * k) rep(j, 1, 2 * k) {
			sum[w][i][j] = sum[w][i - 1][j] + sum[w][i][j - 1] - sum[w][i - 1][j - 1] + a[w][i][j];
		}	
	}
	//printf("%d %d\n", All(0), All(1));
	int res = 0;
	rep(i, 1, k) rep(j, 1, k) {
		int ans[2]; ans[0] = ans[1] = 0;
		rep(w, 0, 1) {
			ans[w] += Get(w, i, j, i + k - 1, j + k - 1);
			ans[w] += Get(w, i + k, 1, 2 * k, j - 1);
			ans[w] += Get(w, i + k, j + k, 2 * k, 2 * k);
			ans[w] += Get(w, 1, j + k, i - 1, 2 * k);
			ans[w] += Get(w, 1, 1, i - 1, j - 1);	
		}
		res = max(res, All(0) - ans[0] + ans[1]);
		res = max(res, All(1) - ans[1] + ans[0]);
		//printf("%d %d %d %d\n", i, j, All(0) - ans[0] + ans[1], All(1) - ans[1] + ans[0]);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 63232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#include <cctype>
#include <map>
#include <iomanip>
                   
using namespace std;
                   
#define eps 1e-8
#define pi acos(-1.0)
#define inf 1<<30
#define linf 1LL<<60
#define pb push_back
#define lc(x) (x << 1)
#define rc(x) (x << 1 | 1)
#define lowbit(x) (x & (-x))
#define ll long long
#define maxn 110

int maz[maxn][maxn];
int n,m;

int stoer_wagner(int n){
    bool vis[maxn];
    int node[maxn],dis[maxn];
    int maxj,prev;
    int ans=inf;
    memset(dis,0,sizeof(dis));
    for (int i=0; i<n; i++)node[i]=i;
    while (n>1) {
        prev=0;
        maxj=1;
        memset(vis,false,sizeof(vis));
        vis[node[0]]=true;
        for (int i=1; i<n; i++) { 
            dis[node[i]]=maz[node[0]][node[i]];
            if (dis[node[i]]>dis[node[maxj]])
                maxj=i; 
        } 
        for (int i=1; i<n; i++) {
            if (i==n-1) { //蜿ェ蜑ゥ譛?錘荳?クェ轤ケ蟆ア蠑?ァ句粋蟷カ轤ケ
                ans=(dis[node[maxj]]<ans?dis[node[maxj]]:ans);
                for (int k=0; k<n; k++) {//蜷亥ケカ轤ケ?梧峩譁ー霎ケ譚??邉サ
                    maz[node[k]][node[prev]]+=maz[node[k]][node[maxj]];
                    maz[node[prev]][node[k]]=maz[node[k]][node[prev]];
                } 
                node[maxj]=node[--n];//郛ゥ轤ケ
            } 
            prev=maxj;
            vis[node[maxj]]=true;
            maxj=-1;
            for (int k=1; k<n; k++) {
                if(!vis[node[k]]) {
                    dis[node[k]]+=maz[node[prev]][node[k]];
                    if(maxj==-1 || dis[node[k]]>dis[node[maxj]])
                        maxj=k; 
                } 
            }
        }
    }
    return ans;
}

int main(){
    while(~scanf("%d%d",&n,&m)){
		if(n==0&&m==0)	break;
        memset(maz,0,sizeof(maz));
        int a,b,c,res=0;            
        for (int i=0; i<m; i++) {
            scanf("%d%d%d",&a,&b,&c);
			if(c<0){
				res+=c;
			continue;
			}
            maz[a][b]+=c;
            maz[b][a]+=c;
        } 
        printf("%d\n",stoer_wagner(n)+res);
    }
    return 0; 
}

Measured memory_bytes: 1240
MAX = 5*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, M = map(int, input().split())
ans = C(M, N)*fact[N]

for i in range(1, N+1):
    if i%2==0:
        ans += C(N, i)*C(M-i, N-i)*fact[N-i]
    else:
        ans -= C(N, i)*C(M-i, N-i)*fact[N-i]
    
    ans %= MOD
    
ans = (ans*C(M, N))%MOD
ans = (ans*fact[N])%MOD
print(ans)

Measured memory_bytes: 91224
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	double A,B,C,D,t1,t2;
	cin>>A>>B>>C>>D;
	t1=ceil(A/D);
	t2=ceil(C/B);
	if(t1>t2){
		cout<<"Yes";
	}else if(t1<t2){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 3256
from sys import stdin
M = int(stdin.readline().rstrip())
D = [0]*M
C = [0]*M

for i in range(M):
    D[i],C[i] = [int(x) for x in stdin.readline().rstrip().split()]

N = 0
S = 0

for j in range(M):
    N += C[j]
    S += D[j]*C[j]

print((N-1)+(S-1)//9)

Measured memory_bytes: 12404
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    H, W, N = map(int, input().split())
    r, c = map(int, input().split())
    S = str(input().strip())
    T = str(input().strip())

    R = c
    L = c
    U = r
    D = r

    i = 0
    while i < N:
        s, t = S[i], T[i]

        if s == 'R':
            R += 1
        elif s == 'L':
            L -= 1
        elif s == 'U':
            U -= 1
        else:
            D += 1

        if R > W or L <= 0 or U <= 0 or D > H:
            return 'NO'

        if t == 'R':
            L += 1
            L = min(L, W)
        elif t == 'L':
            R -= 1
            R = max(R, 1)
        elif t == 'U':
            D -= 1
            D = max(D, 1)
        else:
            U += 1
            U = min(U, H)

        i += 1

    return 'YES' 


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3892
#include<stdio.h>
#include<ctype.h>
 
int main(void){
 
    char s;
 
    while(1){
 
        scanf("%c",&s);
 
        if( s != '.' && s!= ' ' && (s<'a'||s>'z'))
            break;
 
        else if(s>='a'&&s<='z')
            printf("%c",toupper(s));
 
        else
            printf("%c",s);
 
 
    }
 
    puts("");
 
    return 0;
}

Measured memory_bytes: 952
#include<cstdio>
#include<vector>
#include<algorithm>
//#include<numeric>
#include<functional>
//#include<string>
//#include<iostream>

using namespace std;
const int one = 1;
const int big = (one<<20);
typedef long long int llint;

int main(void){
	int i,ans=0,N,x;
	vector<int> A;
	vector<int> S;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&x);
		A.push_back(x);
		S.push_back(x);
	}
	sort(S.begin(),S.end());
	for(i=0;i<N;i++){
		if(((lower_bound(S.begin(),S.end(),A[i])-S.begin())%2)!=(i%2)){ ans++; }
	}
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 1276
count = int(input())
Taro_an = []
Hanako_an = []
Ts = 0
Hs = 0
for i in range(count) :
    animal = input().split(" ")
    Taro_an = animal[0]
    Hanako_an = animal[1]
    if Taro_an > Hanako_an :
        Ts += 3
    else :
        if Hanako_an > Taro_an :
            Hs += 3
        else :
            Ts += 1; Hs += 1
print(Ts,Hs)

Measured memory_bytes: 7488
x1, y1, x2, y2 = [int(x) for x in input().split()]

v = [x2 - x1, y2 - y1]
v_rot = [-v[1],  v[0]]
x3, y3 = [x2 + v_rot[0], y2 + v_rot[1]]
x4, y4 = [x1 + v_rot[0], y1 + v_rot[1]]
ans = [x3, y3, x4, y4]

print(" ".join(map(str, ans)))


Measured memory_bytes: 3060
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      ll n,i;
      cin>>n;
      ll arr[n];
      fr(i,0,n)
      cin>>arr[i];
      ll dp[n+1]={0};
      dp[1]=abs(arr[0]-arr[1]);
      fr(i,2,n)
      {
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
      }
      cout<<dp[n-1];
      
       
    }
  return 0;
  }



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

for i in range(1, 1000+1):
    if n == i*(i-1)//2:
        k = i
        break
else:
    print("No")
    exit()

s = [[] for _ in range(k+1)]
num = 0
for i in range(1, k):
    for j in range(i):
        num += 1
        s[i].append(num)
        if j == i-1:
            s[k].append(num)
        else:
            s[j+1].append(num)
print("Yes")
print(k)
for i in range(1, k+1):
    print(k-1, *s[i])


Measured memory_bytes: 9316
s = input()
n = len(s)
a = []
i = 0
ct = 0
for i in range(n):
    a.append(int(s[i]))
i = -1

while ct < 100000000000:
    n = len(a)
    i += 1
    if i >= n - 1: break
    if a[i] == 0 and a[i + 1] == 1:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1
        continue
    elif a[i] == 1 and a[i + 1] == 0:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1

print(ct * 2)


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

int main() {
  int a, b, A;
  
  cin >> a >> b;

  A = (a*b) % 2;
  
  if (A == 1) {
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let k = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    let cum = Cum::new(&a);
    let mut subs = vec![];
    for i in 0..n {
        for j in i..n {
            subs.push(cum.sum(i..j+1));
        }
    }
    let mut ret = 0;
    'outer: for bit in (0..63).rev() {
        let mask = 1i64 << bit;
        let mut cnt = 0;
        for i in 0..subs.len() {
            if (ret | mask) & subs[i] == ret | mask {
                cnt += 1;
                if cnt >= k {
                    ret |= mask;
                    continue 'outer;
                }
            }
        }
    }
    println!("{}", ret);
    return;
}

use std::ops::Range;

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}


#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    /// [l,r)
    fn sum(&self, range: Range<usize>) -> i64 {
        self.s[range.end] - self.s[range.start]
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 9464