akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A, B;
		A = scan.nextInt();
		B = scan.nextInt();

		int sum = A * B;

		if (sum % 2 == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27028
#include<iostream>

int main() {
  char c;
  int i;
  int count1=0, count2=0; //count1 ... 0101..., count2 ... 1010...

  i=0;
  while(std::cin >> c) {
    if(i%2==0) {
      if(c == '1') count1++;
      else count2++;
    }
    else {
      if(c == '0') count1++;
      else count2++;
    }
    i++;
  }

  if(count1 < count2) std::cout << count1;
  else std::cout << count2;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, m; cin >> n >> m;
    VI a(n,-1);
    int s, c;
    REP(i,m){
        cin >> s >> c;
        if(a[s-1] == -1 || a[s-1] == c){
            a[s-1] = c;
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    if(a[0] == 0 && n != 1){
        cout << -1 << endl;
    }
    else{
        REP(i,n){
            if(a[i] == -1 && (i != 0 || n == 1))
                cout << 0;
            else if(a[i] == -1)
                cout << 1;
            else
                cout << a[i];
        }
    }
    return 0;
}

Measured memory_bytes: 256
A=[[int(x) for x in input().split()] for _ in range(3)]
s=[[0 for i in range(3)] for j in range(3)] 

for i in range(int(input())):
  n=int(input())
  for y in range(3):
    for x in range(3):
      if A[y][x]==n:
        s[y][x]=1

a=[]
for i in range(3):
  a.append(s[0][i]*s[1][i]*s[2][i])
  a.append(s[i][0]*s[i][1]*s[i][2])
a.append(s[0][0]*s[1][1]*s[2][2])
a.append(s[0][2]*s[1][1]*s[2][0])

print('Yes' if 1 in a else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if (e-a<=k)
        cout<<"Yay!";
    else
        cout<<":(";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;


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

    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += abs(x[i] - y[i]);
    }
    cout << fixed << setprecision(8) << sum << "\n";

    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += pow(abs(x[i] - y[i]), 2);
    }
    cout << fixed << setprecision(8) << sqrt(sum) << "\n";

    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += pow(abs(x[i] - y[i]), 3);
    }
    cout << fixed << setprecision(8) << cbrt(sum) << "\n";

    double max = abs(x[0] - y[0]);
    for (int i = 1; i < n; i++) {
        if (max < abs(x[i] - y[i])) {
            max = abs(x[i] - y[i]);
        }
    }
    cout << fixed << setprecision(8) << max << "\n";


}

Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  char c;
  cin>>c;
  if(c=='z'){cout<<'a'<<endl;return 0;}
  else cout<<++c<<endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

void solve() {
	int k; cin >> k; k--;
	cout << a[k] << endl;

	return;
}

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

using namespace std;

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

	int n; cin >> n;

	map<string,int> mp;

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

	int mx = 0;
	for(pair<string,int> x : mp) 
		mx = max(mx, x.second);
	
	set< string > st; 

	for(pair<string,int> x : mp)
		if (x.second == mx) st.insert(x.first);


	for(string x : st)
		cout << x << '\n';


	return 0;	
}

Measured memory_bytes: 33280
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if(S=="RRR") {
    cout << 3 << endl;
  }
  if(S=="SRR"||S=="RRS") {
    cout << 2 << endl;
  }
  if(S=="SSR"||S=="RSS"||S=="RSR"||S=="SRS") {
    cout << 1 << endl;
  }
  if(S=="SSS") {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import sys

N = int(input())
A = list(map(int,input().split()))

B = []
for i,a in enumerate(A):
    B.append([a,i])

B.sort(reverse = True)
#%%
def score(org_idx, sorted_idx):
    s,idx = B[org_idx]
    return s*abs(idx-sorted_idx)

dp = [[0]*(N+3) for _ in range(N+3)]
# dp[i][j] : 左からi個，右からj個詰めてある状態の時の最高スコア

for i in range(N+1):
    for j in range(N+1):
        if i+j == N:
            break
        idx = i+j
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]+score(idx,i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j]+score(idx,N-j-1))
        # print('i,j={},{}'.format(i,j))
        # print(dp)
        
ans = 0
for i in range(N):
    ans = max(ans,dp[i][N-i])
print(ans)





Measured memory_bytes: 100972
#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(){
    vector<int> x(5);
    for (auto i = 0; i < 5; i++) {
        cin >> x[i];
        if(x[i] == 0) {
            cout << i + 1 << endl;
        }
    }

    return 0;
}

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N, D;
    cin >> N >> D;
    cout << (int)ceil(1.0 * N / (D * 2 + 1));
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001
#define mod 1000000007

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, d[max][2];
    int cnt=0;
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%d%d", &d[i][0], &d[i][1]);
        if (d[i][0]==d[i][1]) {
            cnt++;
            if (cnt>=3) {
                printf("Yes");
                return 0;
            }
        } else {
            cnt=0;
        }
    }
    
    printf("No");
    
    return 0;
}


Measured memory_bytes: 1740
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int x[6];
    rep(i, 5) cin >> x[i];

    int y = 0, ans = 0;
    rep(i, 5){
        if( 0 != x[i]%10 ){
            y = max(y, 10 - x[i]%10);
            ans += x[i] + (10 - x[i]%10);
        }else{
            ans += x[i];
        }
    }

    cout << ans - y << endl;

    return 0;
}

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (size_t i = 0; i <= a.length(); i++) {
        if (a[i] != b[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3920
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int n;
	bool card[4][13];

	cin >> n;
	memset(card, false, sizeof(card));
	for (int i = 0; i < n; i++)
	{
		char suit;
		int num;

		cin >> suit >> num;

		switch (suit)
		{
			case 'S':
				card[0][num - 1] = true;
				break;

			case 'H':
				card[1][num - 1] = true;
				break;

			case 'C':
				card[2][num - 1] = true;
				break;

			case 'D':
				card[3][num - 1] = true;
				break;

			default:
				break;
		}
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (!card[i][j])
			{
				switch (i)
				{
				case 0:
					cout << "S " << j + 1 << endl;
					break;

				case 1:
					cout << "H " << j + 1 << endl;
					break;

				case 2:
					cout << "C " << j + 1 << endl;
					break;

				case 3:
					cout << "D " << j + 1 << endl;
					break;

				default:
					break;
				}
			}
		}
	}
	return 0;
}

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

int main()
{
    int n,m;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n; i++){
        cin>>s[i];
    }
    cin>>m;
    vector<string> t(m);
    for(int i=0;i<m; i++){
        cin>>t[i];
    }


    vector<int> count(n);
    string line;
    for(int j=0;j<n; j++){
        for(int i=0; i<n; i++){
            if(s[j]==s[i]){
             count[j]++;
             line=s[j];
            }
        }
    }
    
    for(int j=0;j<n;j++){
        for(int i=0;i<m;i++){
            if(t[i]==s[j]){
                count[j]--;
            }
        }

    }
    int a;
    for(int i=0;i<n;i++){
        a=max(count[i],a);
    }
    cout<<a<<endl;
    
    /*int smax=0;
    for(int j=0;j<n; j++){
        smax=max(count[j],smax);

    }
    
    int red=0;
    for(int i=0;i<m;i++)
    {
    if(line==t[i]){
        red++;
    }
    }
    cout<<smax-red<<endl;*/




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
long long  n,a[200000],b=0;
  cin>>n;
  for(long long i=1;i<=n;i++){
    cin>>a[i];
  }
  long long min=a[1];
  for(int i=2;i<=n;i++){
    if(a[i]>min){
      b++;
    }else{
      min=a[i];
    }
  }
  cout<<n-b<<"\n";
}

Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
}

Measured memory_bytes: 26592
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N-1; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int[] index = new int[N];
		int[] nowA = new int[N];
		for (int i = 0; i < N; i++) {
			nowA[i] = A[i][0];
		}
		int[] lastMoved = new int[N];
		for (int i = 0; i < N; i++) {
			lastMoved[i] = i;
		}
		int lastMovedSize = N;
		int[] nextLastMoved = new int[N];

		boolean[] moved = new boolean[N];
		int day = 0;
		while (true) {
			int nextLastMovedSize = 0;
			boolean anyMove = false;
			Arrays.fill(moved, false);
			for (int x = 0; x < lastMovedSize; x++) {
				int i = lastMoved[x];
				int j = nowA[i] - 1;
				if (j < 0) continue;
				if (moved[i]) continue;
				if (moved[j]) continue;
				if (nowA[j] - 1 != i) continue;
				anyMove = true;
				moved[i] = true;
				moved[j] = true;
				nowA[i] = A[i][++index[i]];
				nowA[j] = A[j][++index[j]];
				nextLastMoved[nextLastMovedSize++] = i;
				nextLastMoved[nextLastMovedSize++] = j;
			}
			if (anyMove == false) break;
			day++;

			int[] tmp = lastMoved;
			lastMoved = nextLastMoved;
			nextLastMoved = tmp;
			lastMovedSize = nextLastMovedSize;
		}
		boolean isAllOk = true;
		for (int i = 0; i < N; i++) {
			if (index[i] != N - 1) {
				isAllOk = false;
				break;
			}
		}
		if (isAllOk) {
			System.out.println(day);
		} else {
			System.out.println("-1");
		}
	}
}


Measured memory_bytes: 236980
import java.io.BufferedReader;
        import java.io.FileNotFoundException;
        import java.io.FileReader;
        import java.io.IOException;
        import java.io.InputStreamReader;
        import java.io.PrintWriter;
        import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

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

    void solve() {
        int N = in.nextInt();
        int p = getP(N);
        if (N % p == 0) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    int getP(int n) {
        int count = 0;
        while (n > 0) {
            count += (n % 10);
            n = n / 10;
        }
        return count;
    }


    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

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

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

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

}

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

#define endl '\n'

using namespace std;

int N;

int a[3001];

long long dp[3001][3001];

long long ans(int head,int tail,bool judge){

  if(dp[head][tail]!=-1){
    return dp[head][tail];
  }
	     
  if(head>tail){
    return 0;
  }
  
  if(judge){
    return dp[head][tail]=max(ans(head,tail-1,!judge)+a[tail],ans(head+1,tail,!judge)+a[head]);
  }
  else{
    return dp[head][tail]=min(ans(head,tail-1,!judge)-a[tail],ans(head+1,tail,!judge)-a[head]);
  }    
}


int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  memset(dp,-1,sizeof(dp));
  
  cin>>N;

  for(int i=0;i<N;i++){

    cin>>a[i];

  }

  cout<<ans(0,N-1,1)<<endl;
  
  
  return 0;

}


Measured memory_bytes: 70784
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	n := sc.nextInt()
	r := sc.nextInt()

	if n >= 10 {
		fmt.Fprintln(wtr, r)
	} else {
		s := 100 * (10 - n)
		fmt.Fprintln(wtr, r+s)
	}
}

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	static final int INF = (int)1e9 + 7;
	int V,E;
	int[][] cost;
	int[][] dp;
	int start;
	public int dfs(int v,int now){
		if(v == (1 << V) - 1){
			if(cost[now][start] == -1)return INF;
			return cost[now][start];
		}
		if(dp[v][now] != -1)return dp[v][now];
		int ret = INF;
		for(int i = 0;i < V;i++){
			if(((v >> i) & 1) == 1)continue;
			if(cost[now][i] == -1)continue;
			ret = Math.min(ret,dfs(v | (1 << i),i) + cost[now][i]);
		}
		return dp[v][now] = ret;
	}
	
    public void solve() {
		V = nextInt();
		E = nextInt();
		
		cost = new int[V][V];
		dp = new int[1 << V][V + 1];
		for(int i = 0;i < V;i++){
			Arrays.fill(cost[i],-1);
		}
		for(int i = 0;i < E;i++){
			int s = nextInt();
			int t = nextInt();
			int d = nextInt();
			cost[s][t] = d;
		}
		int ans = INF;
		for(int k = 0;k < V;k++){
			for(int i = 0;i < 1 << V;i++){
				for(int j = 0;j < V + 1;j++){
					dp[i][j] = -1;
				}
			}
			start = k;
			ans = Math.min(ans,dfs(1 << k,k));
		}
		out.println(ans == INF ? - 1 : ans);
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

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

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

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

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

int main(){
    int n,m,i,j;
    long long ans = 0;
    cin >> n >> m;
    vector<long long> a(n);
    vector<pair<long long ,int>> c(m);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < m;i++){
        cin >> c[i].second >> c[i].first;
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end(),greater<pair<long long ,int>>());

    j = 0;
    for(i = 0;i < n;i++){
        if(a[i] < c[j].first){
            a[i] = c[j].first;
            c[j].second--;
            if(j < m && c[j].second == 0)j++;
        }
    }
    for(int i= 0;i < n;i++){
        ans += a[i];
    }
    cout << ans << endl;
}


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

int main(void) {
    int A[3][3] = {0};

    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    bool R[3][3] = {false};
    for (int k=0; k<N; k++) {
        int b;
        cin >> b;
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                if (b == A[i][j]) R[i][j] = true;
            }
        }
    }

    bool result = false;
    if ((true == R[0][0]) && (true == R[0][1]) && (true == R[0][2])) result = true;
    if ((true == R[1][0]) && (true == R[1][1]) && (true == R[1][2])) result = true;
    if ((true == R[2][0]) && (true == R[2][1]) && (true == R[2][2])) result = true;

    if ((true == R[0][0]) && (true == R[1][0]) && (true == R[2][0])) result = true;
    if ((true == R[0][1]) && (true == R[1][1]) && (true == R[2][1])) result = true;
    if ((true == R[0][2]) && (true == R[1][2]) && (true == R[2][2])) result = true;

    if ((true == R[0][0]) && (true == R[1][1]) && (true == R[2][2])) result = true;
    if ((true == R[2][0]) && (true == R[1][1]) && (true == R[0][2])) result = true;

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

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) cin >> A[i];
  
  int max=A[0], min=A[0];
  for(int i=1; i<N; i++){
    if(A[i]>max)max=A[i];
    if(A[i]<min)min=A[i];
  }
  
  cout << max - min << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int i,b,c,d,e,g;
    for(i=0; i<4; i++)
    {
        b=a[0]-'0';
        c=a[1]-'0';
        d=a[2]-'0';
        g=a[3]-'0';
    }
    int f;
    e=b*10+c;
    f=d*10+g;
    if(e>0&&e<=12&&f>0&&f<=12)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(e>0&&e<=12)
        cout<<"MMYY"<<endl;
    else if(f>0&&f<=12)
        cout<<"YYMM"<<endl;
    else
        cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// 二次元累積和
// v は 1列目と1行目に0を追加した累積和を取りたいやつの配列
void integrate(vector<vector<int> >& v){
  const int n = 1010, m = 1010;
  FOR(i,0,n) FOR(j,0,m-1) v[i][j+1] += v[i][j]; // 横足して行く
  FOR(i,0,n-1) FOR(j,0,m) v[i+1][j] += v[i][j]; // 縦足して行く - > これで2次元の累積和になる！！！
}
int N, K;
int x[100005], y[100005];
string c[100005];
vector<vector<int> > vw_w(1010, vector<int>(1010, 0)), vw_b(1010, vector<int>(1010, 0)), vb_w(1010, vector<int>(1010, 0)), vb_b(1010, vector<int>(1010, 0));//wで希望w、wで希望b 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  FOR(i,0,N) cin >> x[i] >> y[i] >> c[i];
  //(0,0)->(k-1,k-1)をまず白
  FOR(i,0,N) {
    int X = x[i] % K + 1;
    int Y = y[i] % K + 1;
    bool isB = ((x[i] % (2 * K)) >= K) ^ ((y[i] % (2 * K)) >= K);
    if(isB) {
      if(c[i][0] == 'B') {
        vb_b[X][Y]++;
      } else {
        vb_w[X][Y]++;
      }
    } else {
      if(c[i][0] == 'W') {
        vw_w[X][Y]++;
      } else {
        vw_b[X][Y]++;
      }
    }
  }
  integrate(vw_w);
  integrate(vw_b);
  integrate(vb_w);
  integrate(vb_b);
  int ans = 0;
  FOR(i,1,K+1) {
    FOR(j,1,K+1) {
      int cnt = 0;
      // (0,0)->(i,j)を変更しない
      cnt += vw_w[i][j];
      cnt += vw_w[K][K] - vw_w[i][K] - vw_w[K][j] + vw_w[i][j];
      cnt += vw_b[K][j] - vw_b[i][j];
      cnt += vw_b[i][K] - vw_b[i][j];

      cnt += vb_b[i][j];
      cnt += vb_b[K][K] - vb_b[i][K] - vb_b[K][j] + vb_b[i][j];
      cnt += vb_w[K][j] - vb_w[i][j];
      cnt += vb_w[i][K] - vb_w[i][j];
      ans = max(ans, cnt);

      // 変更する
      cnt = 0;
      cnt += vw_b[i][j];
      cnt += vw_b[K][K] - vw_b[i][K] - vw_b[K][j] + vw_b[i][j];
      cnt += vw_w[K][j] - vw_w[i][j];
      cnt += vw_w[i][K] - vw_w[i][j];

      cnt += vb_w[i][j];
      cnt += vb_w[K][K] - vb_w[i][K] - vb_w[K][j] + vb_w[i][j];
      cnt += vb_b[K][j] - vb_b[i][j];
      cnt += vb_b[i][K] - vb_b[i][j];
      ans = max(ans, cnt);
    }
  }
  ans = max(ans, vw_w[K][K] + vb_b[K][K]);
  ans = max(ans, vw_b[K][K] + vb_w[K][K]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 22528
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int gyou = Integer.parseInt(sc.next());
		int retu = Integer.parseInt(sc.next());
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		int[][] i = new int[retu][gyou];
		
		for(int j = 0; j < retu; j++) {
			for(int k = 0; k < h ; k++) {
				i[j][k] = 1;
				i[j][k] = 1;
				i[j][k] = 1;
			}
		}
		
		for(int j = 0; j < gyou; j++) {
			for(int k = 0; k < w ; k++) {
				i[k][j] = 1;
				i[k][j] = 1;
				i[k][j] = 1;
			}
		}
		
		int count = 0;
		
		for(int j = 0; j < gyou; j++) {
			for(int k = 0; k < retu; k++) {
				if(i[k][j] == 1) {
					count++;
				}
			}
		}
		System.out.println((gyou * retu) - count);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    string s;
    cin>>s;
    int flag=1;
    for(int i=0;i<s.size();++i){
        if(((i&1)==0 && s[i]=='L') || (i&1 && s[i]=='R') ){
            flag=0;
            break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool f(vector<int>& a, int target, int k){
    int t=0, i=0;
    while(t<=k&&i!=a.size()){
        t += (a[i]-1)/target;
        ++i;
    }
    if(t>k) return false;
    else return true;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a.rbegin(),a.rend());
    int maxi = a[0];
    int mini = 0;

    while(1){
        int now = (maxi + mini)/2;
        if(now==0) break;
        bool ret = f(a,now,k);
        if(ret) maxi = now;
        else mini = now;
        if(maxi == mini+1) break;
    }
    cout << maxi << endl;

    return 0;
}

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

using namespace std;

int main() {
	int H, W, h, w;
	cin >> H >> W;
	cin >> h >> w;
	int total = H * W;
	total -= h * W;
	total -= (H-h) * w;
	cout << total << endl;
	return 0;
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            string[] str = input.Split(' ');
            int vartical = int.Parse(str[0]);
            int holizonatal = int.Parse(str[1]);

            Console.WriteLine("{0} {1}", vartical * holizonatal, 2 * (vartical + holizonatal));
        }
    }
}



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

int main() {

  long long a,b,c,x;
  cin>>a>>b>>c>>x;
   long long ans=0;

   for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
        for(int k=0;k<c+1;k++){
            if(500*i + 100*j + 50*k == x)
                ans++;
        }
    }
   }

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long N, long long L, std::vector<long long> a)
{
    vector<int> ans;
    for (int i = 1; i < N; i++)
    {
        if (a[i] + a[i - 1] >= L)
        {
            cout << YES << endl;
            ans.push_back(i);
            for (int j = i - 1; j >= 1; j--)
            {
                ans.push_back(j);
            }
            for (int j = i + 1; j <= N - 1; j++)
            {
                ans.push_back(j);
            }
            reverse(ans.begin(),ans.end());          
            for (auto &&i : ans)
            {
                cout << i << endl;
            }
                        

            return;
        }
    }
    cout << NO << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long L;
    scanf("%lld", &L);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, L, std::move(a));
    return 0;
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForLong(i, n) for (int64 i = 0; i < (n); ++i)
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))



int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> lines(h);
	ForInt(i, h)
	{
		cin >> lines[i];
	}

	vector<vint> l(h, vint(w));
	vector<vint> r(h, vint(w));
	vector<vint> u(h, vint(w));
	vector<vint> d(h, vint(w));

	ForInt(i, h)
	{
		l[i][0] = lines[i][0] == '#' ? 0 : 1;
		r[i][w - 1] = lines[i][w - 1] == '#' ? 0 : 1;
		ForIntInit(j, 1, w)
		{
			l[i][j] = lines[i][j] == '#' ? 0 : l[i][j - 1] + 1;
			r[i][w - 1 - j] = lines[i][w - 1 - j] == '#' ? 0 : r[i][w - j] + 1;
		}
	}

	ForInt(j, w)
	{
		u[0][j] = lines[0][j] == '#' ? 0 : 1;
		d[h - 1][j] = lines[h - 1][j] == '#' ? 0 : 1;
		ForIntInit(i, 1, h)
		{
			u[i][j] = lines[i][j] == '#' ? 0 : u[i - 1][j] + 1;
			d[h - 1 - i][j] = lines[h - 1 - i][j] == '#' ? 0 : d[h - i][j] + 1;
		}
	}

	int max = 0;
	ForInt(i, h)
	{
		ForInt(j, w)
		{
			max = Max(max, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
		}
	}
	cout << max << endl;

	return 0;
}

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



int main() {
  string s;
  cin>>s;
  if(s[s.length()-1]!='s')s.append("s");
  else s.append("es");

  cout<<s<<endl;
  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 55;
const int MAXM = 500;
 
struct Edge
{
    int to,next;
}edge[MAXM];
int head[MAXN],tot;
int Dfn[MAXN],Low[MAXN];
int Index,res;
 
void addedge(int u, int v)
{
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
}
 
void Tarjan(int u, int fa)
{
    Dfn[u] = Low[u] = ++Index;
    for(int i = head[u]; i != -1; i = edge[i].next)
    {
        int v = edge[i].to;
        if(!Dfn[v])
        {
            Tarjan(v,u);
            Low[u] = min(Low[u],Low[v]);
            if(Low[v] > Dfn[u])
                ++res;
        }
        else if(v != fa)
            Low[u] = min(Low[u],Dfn[v]);
    }
}
 
void solve(int n)
{
    Index = res = 0;
    memset(Dfn,0,sizeof(Dfn));
    memset(Low,0,sizeof(Low));
    Tarjan(1,-1);
    printf("%d\n",res);
}
 
int main()
{
    int n,m,u,v;
    memset(head,-1,sizeof(head));
    tot = 0;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m; ++i)
    {
        scanf("%d %d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    solve(n);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct edge{int from, to, coin;};
edge es[5500];
vector<int> G[3030];

int d[3000], dd[3000];
int N, M, P;

void dfs(int v, bool used[]) {
    if(used[v]) return ;
    used[v] = true;
    for(auto u : G[v]) {
        dfs(u, used);
    }
}

bool used1[3030], used2[3030];

pair<int, bool> shortest_path(int s) {
    rep(i, N) {
        d[i] = INF;
    }
    d[s] = 0;
    int cnt = 0;
    while(true) {
        cnt ++;
        bool update = false;
        rep(i, M) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.coin) {
                d[e.to] = d[e.from] + e.coin;
                update = true;
                if(used1[e.to]) {
                    if(cnt > 2 * N) {
                        rep(j, N) used2[j] = false;
                        dfs(e.to, used2);
                        if(used2[N - 1]) return make_pair(-1, false);
                    }
                }
            }
        }
        if(!update) break;
        if(cnt > 3 * N) break;
    }
    return make_pair(d[N - 1] * (-1), true);
}

bool find_negativeloop() {
    memset(dd, 0, sizeof(dd));
    rep(i, N) {
        rep(j, M) {
            edge e = es[j];
            if(d[e.to] > d[e.from] + e.coin) {
                d[e.to] = d[e.from] + e.coin;
                if(i == N - 1) return true;
            }
        }
    }
    return false;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M >> P;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a --; b --;
        es[i] = edge{a, b, (-1) * (c - P)};
        G[a].pb(b);
    }
    rep(i, N) used1[i] = false;
    dfs(0, used1);
    pair<int, bool> ans = shortest_path(0);
    if(ans.sc == false) {
        cout << -1 << endl;
    } else {
        int res = ans.fr;
        if(res < 0) res = 0;
        cout << res << endl;
    }
    
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n, m;
	int f = 0;
	cin >> n >> m;
	if (n == 0) { cout << 0; return 0; }
	int p = n % m;
	if (p == 0) { cout << 0; return 0; }
	if (n >= m)
	{
		long long t = n / m;
		// cout << t;
		while (t != 0) {
			n = n - t * m;
			t = n / m;
		}
		long long ans;
		ans = min(n,abs(n-m));
		cout << ans;
	}
	else {
		long long ans;
		ans = min(m - n, n);
		cout << ans;
	}

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int x,n,temp;
	scanf("%d %d",&x,&n);
	int p[102]={0};
	for(int i=0;i<n;i++){
		scanf("%d",&temp);
		p[temp]=1;
	}
	int ans;
	for(int i=0;;i++){
		ans=x-i;
		if(p[ans]==0)break;
		ans=x+i;
		if(p[ans]==0)break;
	}
	printf("%d",ans);
	
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int R;
    cin>>R;
    
    if(R<1200){
        cout<<"ABC"<<endl;
    }
    else if(R<2800){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"AGC"<<endl;
    }
    
   
}

Measured memory_bytes: 3564
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	string a, t;
	cin >> a >> t;
	int ans = MOD;
	rep(i, a.size()) {
		int tmp = 0;
		rep(j, t.size()) {
			if (i + j == a.size())
			{
				tmp = MOD;
				break;
			}
			if (a[i + j] != t[j])
			{
				tmp++;
			}
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	system("pause");
}



Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int m = 1;
    for (int i = 0;i < 10000;i++) {
      if(s == 4 || s == 2 || s == 1) {
        break;
	  }
      if(s % 2 == 0) {
        s = s / 2;
        m = m + 1;
	  }
      else {
        s = (s * 3) + 1;
		m = m + 1;
	  }
	}
    m = m + 3;
	System.out.println(m);
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
	comInit();
	ll n,k; cin >> n >> k;
	if(n <= k+1) cout << com(2*n-1,n) << endl;
	else{
		ll ans = 0;
		rep(i,k+1){
			ans += com(n,i)*com(n-1,i)%mod;
			ans %= mod;
		}
		cout << ans << endl;
	}
}

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

using namespace std;
#define ll long long int
ll m = 1e9+7;
vector<ll> cnt,ans;
ll po(ll a, ll b){
    ll ans = 1;
    while(b>0){
        if(b%2==1){
            ans = ans*a;
            ans %= m;
        }
        b/=2;
        a = (a*a)%m;
        //a %= m;
    }
    return ans;
}


int main()
{
    ll n, k;
    cin >> n >> k;
    ans.resize(k+1);
    cnt.resize(k+1);
    for(ll i=k;i>=1;i--){
        ans[i] = po(k/i,n);
        ans[i] %= m;
        for(ll j=i*2;j<=k;j+=i){
            ans[i] -= ans[j];
            ans[i] %= m;
        }
    }
    ll ans1 = 0;
    for(ll i=1;i<=k;i++){
        ans1 += (i%m * ans[i]%m)%m;
        ans1 %= m;
    }
    cout << ans1 << endl;
}


Measured memory_bytes: 4756
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    C = Counter(list(map(int, input().split())))

    s1 = list(sorted([k for k, v in C.items() if v >= 2], reverse=True))
    s2 = list(sorted([k for k, v in C.items() if v >= 4], reverse=True))

    ans = 0
    if len(s1) >= 2:
        ans = max(ans, s1[0] * s1[1])
    if len(s2) >= 1:
        ans = max(ans, s2[0] ** 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  ll sum = 0;
  vector<ll> L(N);
  rep(i,N) cin >> L[i];
  sort(L.begin(), L.end(), greater<ll>());
  rep(i,K) sum += L[i];
  cout << sum << endl;
  return 0;
}


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

const int maxn = 100000 + 10;
int fa[maxn];

set <int> st;

int find(int id)
{
    if (fa[id] == id)
    {
        return id;
    }
    fa[id] = find(fa[id]);
    return fa[id];
}

void pre(int n)
{
    for (int i = 1; i <= n; i++)
    {
        fa[i] = i;
    }
}


int main()
{
    int n = 0, m = 0;   cin >> n >> m;
    pre(n);
    for (int i = 0; i < m; i++)
    {
        int a = 0, b = 0, c = 0;
        cin >> a >> b >> c;
        int aa = find(a), bb = find(b);
        if (aa != bb)
        {
            fa[aa] = bb;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        st.insert(find(i));
    }
    cout << st.size() << '\n';
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 5376