akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    cout << (N-2)*180 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int a=0,b=0,c=0,count=0,n=0,z=0,i=0,j=0,k=0;
      	//cin >> a >> b >> c;
      	cin >> n;
      	ll int arr[n+1];
      	memset(arr,0,sizeof(arr));
      	//arr[6] = 1;
      	for(i=1;i<=100;i++){
        	for(j=1;j<=100;j++){
            	for(k=1;k<=100;k++){
                	if(i*i + j*j + k*k + i*j + j*k + k*i <=n){
                    	arr[i*i + j*j + k*k + i*j + j*k + k*i ]++;
                    }
                }
            }
        }
      for(i=1;i<=n;i++){
      	cout << arr[i]<<endl;
      }
	}
}

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

int main() {
    double r;
    double a = 3.141592653589;
    cin >> r;
    double s = r * r * a;
    double l = 2 * r * a;

        cout << fixed;
        cout << s << " " << l << endl;

    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	double m, max_m=-1.0, min_m=1000000000;
	while (cin >> m) {
		min_m = min(min_m, m);
		max_m = max(max_m, m);
	}
	double ans = max_m - min_m;
	cout << ans << endl;
}

Measured memory_bytes: 0
import java.io.*;
public class Main{
    static int H, W;
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        {int[] a = r.ii(); H = a[0]; W = a[1];} 
        char[][] S = new char[H][];
        int[][] direction = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, 
                             {0, 1}, {1, -1}, {1, 0}, {1,1}};
        int inf = Integer.MIN_VALUE;
        for(int i = 0; i < H; i++)
            S[i] = r.s().toCharArray();
        int[][] num = new int[H][W];
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(S[i][j] == '#'){
                    num[i][j] = inf;
                    for(int[] d : direction){
                        int x = i+d[0];
                        int y = j+d[1];
                        if(exists(x, y)){
                            num[x][y]++;
                        }                        
                    }
                }
            }
        }
        for(int[] n : num){
            for(int k : n)
                if(k >= 0)
                    print(k);
                else
                    print('#');
            println("");
        }
    }
    static boolean exists(int i, int j){
        return 0 <= i && i < H && 0 <= j && j < W;
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <stdio.h>

using namespace std;


int main(){

int w,h,x,y,r;

scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

int x_p = x + r;
int x_m = x - r;
int y_p = y + r;
int y_m = y - r;



if(x_m < 0 || y_m < 0){
cout << "No" << endl;
return 0;
}

if(x_p > w || y_p > h){
cout << "No" << endl;
return 0;

}

cout << "Yes" << endl;
return 0;

}




Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n + 1, vector<int>(0));
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    int node = 0;
    for (int i = 1; i <= n; i++) {
        if (v[i].size() == 1) {
            node = i;
            break;
        }
    }
    vector<int> visited(n + 1, 0);
    visited[node] = 1;
    long long int res = (long long int)node * (long long int)(n - node + 1);
    vector<int> v1, v2;
    v1.push_back(node);
    while (v1.size() > 0) {
        v2.clear();
        for (auto now : v1) {
            for (auto next : v[now]) {
                if (visited[next] == 0) {
                    if (now < next) {
                        res += (long long int)(next - now) * (long long int)(n - next + 1);
                    } else {
                        res += (long long int)(now - next) * (long long int)next;
                    }
                    visited[next] = 1;
                    v2.push_back(next);
                }
            }
        }
        v1 = v2;
    }
    cout << res << endl;
}


Measured memory_bytes: 17160
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, M;
    cin >> N >> M;
    ll sec[N];
    fill(sec, sec + N, 1000000);
    for (int i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        sec[a - 1] = min(sec[a - 1], b - 1);
    }
    // for (int i = 0; i < N; i++) {
    //     cout << sec[i];
    // }
    ll ans = 0;
    ll nex = 1000000;
    for (int i = 0; i < N; i++) {
        nex = min(nex, sec[i]);
        //cout << nex << endl;
        if (nex == i + 1) {
            ans++;
            nex = 1000000;
        }
    }
    if (nex != 1000000) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int A;
  int B;
  int T;
  int ans = 0;
  int time = 0;
  int cnt = 1;

  cin >> A >> B >> T;

  time += A;
  while(time <= T){
    ans += B;
    time += A;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt(),M=sc.nextInt(),K=sc.nextInt();
		int[] counts = new int[N+1];
		UnionFindTree tree = new UnionFindTree(N+1);
		for(int i=0;i<M;i++) {
			int A =sc.nextInt(),B=sc.nextInt();
			counts[A]++;
			counts[B]++;
			tree.union(A, B);
		}
		for(int i=0;i<K;i++) {
			int C =sc.nextInt(),D=sc.nextInt();
			if(tree.same(C,D)) {
				counts[C]++;
				counts[D]++;
			}
		}
		for(int i=1;i<N+1;i++) {
			int ans = tree.getSize(i)-counts[i]-1;
			System.out.print(ans+" ");
		}
	}

}



class UnionFindTree {
	int[] parent;
	int[] height;
	int[] size;
	
	UnionFindTree(int size) {
		this.parent = new int[size];
		this.height = new int[size];
		this.size = new int[size];
		
		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}
	
	void makeSet(int i) {
		parent[i] = i;
		height[i] = 0;
		size[i] = 1;
	}
	
	int find(int x) {
		if (x != parent[x]) {
			parent[x] = find(parent[x]);
		}
		return parent[x];
	}
	
	void union(int x, int y) {

		int rootX = find(x);
		int rootY = find(y);
		
		if (rootX == rootY) { //既に結合済み
			return;
		}
		
		if (height[rootX] > height[rootY]) {
			parent[rootY] = rootX;
			size[rootX] += size[rootY];
			
		} else if (height[rootX] < height[rootY]) {
			parent[rootX] = rootY;
			size[rootY] += size[rootX];
			
		} else {
			parent[rootY] = rootX;
			size[rootX] += size[rootY];
			height[rootX]++;
		}
	}
	int getSize(int x) {
		int rootX = find(x);
		return size[rootX];
	}
	
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
	
}
	

Measured memory_bytes: 97352
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main ()
{
    int n;
    while (cin >> n, n) {
        map<string,string> str;
        for (int i = 0; i < n; i++) {
            string str1, str2;
            cin >> str1 >> str2;
            str[str1] = str2;
        }
        cin >> n;
        for (int i = 0; i < n; i++) {
            string str1;
            cin >> str1;
            if (str.find(str1) != str.end()) cout << str[str1];
            else cout << str1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
N=int(input())
A=list(map(int,input().strip().split()))
k=1
f=0
if 0 in A:
	print(0)
else:
	for i in range(N):
		k=k*A[i]
		if k>10**18:
			f=1
			break
	if f==1:
		print(-1)
	else:
		print(k)

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

int main(void){
  int N;
  cin >> N;
  vector<int> kusi(2*N);
  for(int i=0;i<2*N;i++){
    int a;
    cin >> a;
    kusi.at(i)=a;
  }
  sort(kusi.begin(),kusi.end());
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=kusi.at(2*i);
  }
  cout << ans << endl;
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
map<int, int> prime_factor(int n) {
	map<int, int > ret;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	int tmp = gcd(a, b);
	int cnt = 1;
	map<int, bool>mp;
	for (auto p : prime_factor(tmp)) {
		while (p.second--) {
			if (mp[p.first] == false) {
				mp[p.first] = true;
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < S.length() / 2; i++){
    if (S[i] != S[S.length() -1 - i]){
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static TreeSet<Long> set;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int k = sc.nextInt();
		set = new TreeSet<Long>();
		for (int i = 0; i < 10; i++) {
			dp(i+"");
		}
		set.remove(0l);
		for(long l:set) {
			k--;
			if(k == 0) {
				out.println(l);break;
			}				
		}
		
		out.close();
	}
	static void dp(String s) {
		set.add(Long.parseLong(s));
		if(s.length() == 10)
		{
			return;
		}
		char c = s.charAt(0);
		dp(c+s);
		if(c < '9') {
			char c2 = (char) (c+1);
			dp(c2+s);			
		}
		if(c > '0') {
			char c3 = (char) (c-1);
			dp(c3+s);			
		}
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}

}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int a[5],i,ans=0;
	REP(i,0,4) {
		cin>>a[i];
		if(a[i]==0) ans=i+1;
	}
	cout<<ans;
	return 0;
}




Measured memory_bytes: 3660
using System;
using System.Linq;
using static System.Console;

class class_A
{
    static int calc(int n0)
    {
        var result = 0;
        var n = n0;
        while (n != 0)
        {
            result += n % 10;
            n /= 10;
        }
        return result;
    }

    static void Main()
    {
        var tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = tmp[0];
        var A = tmp[1];
        var B = tmp[2];

        var ans = 0;

        for (var n = 0; n <= N; n++)
        {
            var calc_n = calc(n);
            if (A <= calc_n && calc_n <= B)
            {
                ans += n;
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define P(s) cout << s << "\n"

int main() {
    unordered_map<string, int32_t> word;

    int32_t n;
    cin >> n;
    for (auto i = 0; i < n; ++i) {
        string s;
        cin >> s;
        word[s]++;
    }

    int32_t m;
    cin >> m;
    for (auto i = 0; i < m; ++i) {
        string t;
        cin >> t;
        word[t]--;
    }

    auto res = 0;
    for (const auto& w: word) {
        res = max(res, w.second);
    }

    P(res);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int t[100][100],h,w,n;
void init(){
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++)
      t[i][j]=0;
  t[0][1]=1;
}
int main(){
  while(cin>>h>>w&&h&&w){
    cin>>n;
    init();
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      t[a][b]=-1;
    }
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	if(t[i][j]==-1){t[i][j]=0;continue;}
	t[i][j]+=t[i-1][j];
	t[i][j]+=t[i][j-1];
      }
    }
    cout<<t[h][w]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}

int N, K, C;
int F[200100],B[200100];
int szf[200100], szb[200100];
string S;
int main()
{
	cin >> N >> K >> C;
	cin >> S;
	F[1] = 1;
	int res = 1;
	for(int i =1;i<N+1;i++) {
		F[i] = F[res];
		
		if (i - res > C&&S[i-1]=='o') {
			F[i] = F[res]+1;
			res = i;
		}
		szf[i] = res;
	}
	res = N;
	B[res] = 1;
	for (int i = N; i > 0; --i) {
		B[i] = B[res];
		if (res - i > C&& S[i-1] == 'o') {
			B[i] = B[res]+1;
			res = i;
		}
		szb[i] = res;
	}
	szf[0] = -INF; szb[N + 1] = INF;
	int ans = 0;
     for(int i=1;i<N+1;i++) {
		int sum = F[i-1] + B[i+1];
		if (abs(szf[i-1] - szb[i+1]) <= C ) {
			sum--;
		}
		//cout << i<<" "<<sum << endl;
		if (sum < K&& S[i-1] == 'o') {
			cout << i << endl;
		}
	}
	
	
}

Measured memory_bytes: 4996
#include <iostream>
#include <algorithm>

using namespace std;

int dp[100005];
int nums[100005];

int main(void)
{
    int n;
    cin >> n;
    fill_n(dp, 100005, INT32_MAX);
    for(int i=1; i <= n; ++i)
    {
        cin >> nums[i];
    }

    dp[1] = 0;

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

    cout << dp[n] << '\n';
}

Measured memory_bytes: 1024
W, H, N = map(int, input().split())
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        maxy = min(maxy, y)

    ans = (maxx - minx) * (maxy - miny)
print(ans if minx < maxx and miny < maxy else 0)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
string s[55];
int memo[55][30];
int main(void){
	cin >> n;
	rep(i, n) cin >> s[i];
	rep(i, n){
		string d = s[i];
		rep(j, d.size()) memo[i][d[j] - 'a']++;
	}
	string ans = "";
	rep(j, 26){
		int ma = INF;
		rep(i, n){
			chmin(ma, memo[i][j]);
		}
		rep(i, ma) ans += ('a' + j);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b, c;

int main(){
	cin >> a >> b >> c;
	int ans = a + b + c;
	if (ans < 22){
		cout << "win" << endl;
	}
	else{
		cout << "bust" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int N,M,Q;
int a[51],b[51],c[51],d[51];
int A[11];
int Ma=0;

int calc(){
	int ans=0;
	for(int i=1;i<=Q;i++){
		if(A[b[i]] - A[a[i]] == c[i])ans+=d[i];
	}
	return ans;
}

void dfs(int s,int t){

	if(s == N+1){
		int ret = calc();
		Ma = max(ret,Ma);
		return ;
	}
	for(int i=t;i<=M;i++){
		A[s] = i;
		dfs(s+1,i);
	}
}

int main(){
	cin >> N >> M >> Q;
	for(int i=1;i<=Q;i++)cin >> a[i] >> b[i] >> c[i] >> d[i];
	for(int i=1;i<=M;i++){
		dfs(1,i);
	}
	cout << Ma << endl;
	return 0;
}

Measured memory_bytes: 3632
using System;

public class hello
{
    public static void Main()
    {
        var a = new string[] { "rulu", "luru", "rdld", "ldrd" };
        while (true)
        {
            var n = Console.ReadLine().Trim();
            if (n == "0") break;
            var s = Console.ReadLine().Trim().Replace(" ", "");
            var sL = s.Length;
            for (int i = 0; i < 4; i++)
                s = s.Replace(a[i], "@");
            var ans = (sL - s.Length) / 3;
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 15812
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli k;
    vector<pair<lli, lli>> e[100005];
    cin >> k;
    rep(i, k)
    {
        e[i].push_back(make_pair((i + 1) % k, 1));
        e[i].push_back(make_pair((i * 10) % k, 0));
    }
    priority_queue<pair<lli, lli>, vector<pair<lli, lli>>, greater<pair<lli, lli>>> que;
    que.push(make_pair(1, 1));
    lli dist[100005] = {};
    rep(i, 100005) dist[i] = 1e10;
    while (!que.empty()) {
        auto s = que.top();
        que.pop();
        lli cur = s.first;
        lli d = s.second;
        if (d > dist[cur]) {
            continue;
        }
        dist[cur] = min(dist[cur], d);
        for (auto to : e[cur]) {
            int nxt = to.first;
            lli c = to.second;
            if (dist[nxt] <= c + d) {
                continue;
            }
            dist[nxt] = c + d;
            que.push(make_pair(nxt, c + d));
        }
    }
    cout << dist[0] << endl;
}


Measured memory_bytes: 13168
#include <stdio.h>
#include <string.h>
int main(void){
    char s[1000],ss[10000];
    int n,count;
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%s",ss);
    for(count=0;count<n;count++){
        printf("%c",s[count]);
        printf("%c",ss[count]);
    }
  printf("\n");
}

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

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

  int a=n/100;
  int b=n/10-a*10;
  int c=n%10;

  if (n==100*c+10*b+a) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

using namespace std;

int h[100002]; /// Heights
int dp[100002]; /// dp table

int go(int pos) {
    if (pos == 0) return 0;

    if(dp[pos] != -1) return dp[pos];
    
    int ans = 1 << 30;

    for (int i = 1; i <= 2; i++) {
        if (pos - i < 0) break;

        ans = min(ans, abs(h[pos] - h[pos - i]) + go(pos - i));
    }

    return dp[pos] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n;
    cin >> n;

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

    memset(dp, -1, sizeof dp);
    
    cout << go(n - 1) << endl;
}

/**
 * Frog 1
 */

Measured memory_bytes: 5760
import sys

a_max = 10000000000

def merge_sort(A):
	n = len(A)
	num_swap = 0

	if n > 1:
		m = n // 2
		num_swap0, A0 = merge_sort(A[0:m])
		num_swap1, A1 = merge_sort(A[m:])
		
		num_swap += num_swap0 + num_swap1

		n1 = len(A0)
		A0.append(a_max)
		A1.append(a_max)	
		i = 0
		j = 0		
		
		for k in range(n):
			if A0[i] < A1[j]:
				A[k] = A0[i]

				i += 1
			else:
				A[k] = A1[j]

				num_swap += n1 - i
				j += 1

	return num_swap, A

def bubble_sort(A):
	n = len(A)
	num_swap = 0

	for i in range(n):
		for j in range(n - 1, i, -1):
			if A[j] < A[j - 1]:
				A[j], A[j - 1] = A[j - 1], A[j]
				num_swap += 1

	return num_swap, A

#fin = open("test.txt", "r")
fin = sys.stdin

fin.readline()
A = list(map(int, fin.readline().split()))

num_swap, B = merge_sort(A)
#num_swap, B = bubble_sort(A)

print(num_swap)
#print(B)

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

int contains(string s, char c){
    for (auto ch : s) {
        if (ch == c) return  1;
    }
    return 0;
}

int main()
{
    int a = 0, b = 0;
    string s;
    cin >> s;
    if (contains(s,'N')) a++;
    if (contains(s,'S')) a--;
    if (contains(s,'E')) b++;
    if (contains(s,'W')) b--;
    if (a==0 && b==0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    ll N,A,B;
    cin >> N >> A >> B;

    if((B-A)%2){
        cout << min({N - A,B - 1,(N-B) + (B-A+1)/2,(A-1) + (B-A+1)/2})  << endl;
    }else{
        cout << (B-A)/2 << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class Combi {
private:
  v(ll) fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
    for (int i = 2; i < N; 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;
    }
  }
public:
  Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  ll Cmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }
  ll Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  if(s[0] == 'W' || s[2*N-1] == 'W') {
    cout << 0 << endl;
    return 0;
  }
  v(bool) isR(2*N,false);
  srep(i,1,2*N) {
    if(s[i] != s[i-1]) {
      isR[i] = isR[i-1];
    } else {
      isR[i] = !isR[i-1];
    }
  }
  int cnt = 0;
  rep(i,2*N) {
    if(isR[i]) cnt++;
  }
  if(cnt != N) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  int l = 0;
  rep(i,2*N) {
    if(isR[i]) {
      ans *= l;
      ans %= MOD;
      l--;
    } else {
      l++;
    }
  }
  Combi C = Combi(N);
  ans *= C.Pmod(N,N);
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2948
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    vvint vv;
    string s;
    while(cin>>s){
        vv.PB(vint(0));
        stringstream ss;
        ss<<s;
        int t;
        ss>>t;
        vv.back().PB(t);
        char tt;
        while(ss>>tt){
            ss>>t;
            vv.back().PB(t);
        }
    }
    vint v[2];
    v[0]=vint(1,vv[0][0]);
    reep(i,1,vv.size()){
        v[1]=vint(vv[i].size());
        if(vv[i-1].size()<vv[i].size()){
            rep(j,v[0].size()){
                maxs(v[1][j],v[0][j]);
                maxs(v[1][j+1],v[0][j]);
            }
        }
        else{
            rep(j,v[1].size()){
                v[1][j]=max(v[0][j],v[0][j+1]);
            }
        }
        rep(j,v[1].size()){
            v[1][j]+=vv[i][j];
        }
        swap(v[0],v[1]);
    }
    cout<<v[0][0]<<endl;
}


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

Measured memory_bytes: 1264
#include<stdio.h>
int main(void){
    char S[4];
    scanf("%s",S);
    int n = 0;
    for(int i = 0; i < 4; i++){
        if(S[i] == '+') n++;
        if(S[i] == '-') n--;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128
s=list(input())
a=0
if len(s)%2==1:
    print("No")
    #print("a")
else:
    b=0
    for i in range(len(s)//2):
        if s[b]+s[b+1]!="hi":
            a=1
            break
        b+=2
    print("Yes" if a==0 else "No")

Measured memory_bytes: 3060
n=int(input())
ans=''
for i in range(40,-1,-1):
  if i==0:
    if n==1:
      ans+='1'
      n=n-1
    else:
      ans+='0'
  elif i==1:
    if -2<=n<=-1:
      ans+='1'
      n=n-(-2)
    else:
      ans+='0'
  elif i%2==1:
    l=-(2*(4**((i+1)//2)-1)//3)
    r=-2**i+(1*(4**((i+1)//2)-1)//3)
    if l<=n<=r:
      ans+='1'
      n=n-((-2)**i)
    else:
      ans+='0'
  else:
    l=2**i-(2*(4**(i//2)-1)//3)
    r=1*(4**(i//2+1)-1)//3
    if l<=n<=r:
      n=n-((-2)**i)
      ans+='1'
    else:
      ans+='0'
if '1' not in ans:
  print(0)
else:
  ans=ans[ans.index('1'):]
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=2e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{

	int n , m;
    cin>>n;
    if (n>=30)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3632
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//213
	int n,h;
	cin>>n>>h;
	vi a(n),b(n);
	int mxa = 0;
	REP(i,0,n-1)cin>>a[i]>>b[i],mxa=max(mxa,a[i]);
	sort(b.begin(),b.end());
	int ipos = upper_bound(b.begin(),b.end(),mxa) - b.begin();
	int cnt = 0;
	for(int i=n-1;i>=ipos;i--) {
		h-=b[i];
		cnt++;
		if(h<=0)break;
	}
	if(h>0) cnt+=ceil((double)h/(double)mxa);
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3980
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int cnt=0;
    
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3924
n = int(input())
a = input().split()

b = [0]*n

for i in range(n//2):
    b[i] = a[-1-2*i]
    b[n-i-1] = a[-2-2*i]

if n % 2 == 1:
    b[n//2] = a[0]

print(' '.join(b))


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
  	vi cnt(100100, 0);
  
  	int a;
  	rep(i,n) {
      	cin >> a;
    	cnt[a]++;
    }
  	
  	int ans = 0;
  	int temp = 0;
  	rep(i,100100){
		if(cnt[i]==0) continue;
      	else if(cnt[i]%2==1) ans++;
      	else {
          	temp++;
        	if(temp==2){
            	ans += 2;
              	temp = 0;
            }
        }
    }
  	
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
void swap(int& a, int& b){
	int t=a;
	a = b;
	b = t;
}
 
void solveTest(){
	int A,B,M;
	cin>>A>>B>>M;
	int a[A+1],b[B+1];
	int minA = INT_MAX;
	int minB = INT_MAX;
	for(int i=1;i<=A;i++){
		cin>>a[i];
		if(a[i]<minA){
			minA=a[i];
		}
	}
	for(int i=1;i<=B;i++){
		cin>>b[i];
		if(b[i]<minB){
			minB = b[i];
		}
	}
	int minprice = INT_MAX;
	for(int i=0;i<M;i++){
		int x,y,c;
		cin>>x>>y>>c;
		if((a[x]+b[y]-c)<minprice){
			minprice = a[x]+b[y]-c;
		}
	}
	cout<<min(minA+minB,minprice)<<endl;
	return ;
}
 
int main(){
	fastio();
	//input();
 
	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int a,b,x;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x;
    cin>>a;
    cin>>b;
    x-=a;
    cout<<x%b<<newl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int i, j, k;
  int n, player[600], co;
  int cplayer[600] = {0};

  scanf("%d", &n);

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

  for(i = 0; i < 3; i++){
    for(j = 0; j < n-1; j++){
      co = 0;
      for(k = 0; k < n-j-1; k++){
	if(player[(k+j+1)*3+i] == player[j*3+i]){
	  cplayer[(k+j+1)*3+i] = 1;
	  co = 1;
	}
      }
      if(co == 1) cplayer[j*3+i] = 1;
    }
  }

  for(i = 0; i < n*3; i++){
    if(cplayer[i] == 1) player[i] = 0;
  }

  co = 0;
  
  for(i = 0; i < n; i++){
    printf("%d\n", player[i*co] + player[i*co+1] + player[i*co+2]);
    co = 3;
  }

  return 0;
}

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

#define newline '\n'
#define IOS ios_base::sync_with_stdio(false); cin.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
    IOS;

    int n;
    cin >> n;

    bool zero = false;
    vector<ull> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if (v[i] == 0) {
            zero = true;
        }
    }

    if (zero) {
        cout << 0 << "\n";
        return 0;
    }
    
    const ull lim = 1e18;
    ull ans = 1;

    bool can = true;
    for (int i = 0; i < n; ++i) {
        if (v[i] <= lim / ans) {
            ans *= v[i];
        } else {
            can = false;
            break;
        }
    }

    if (can) {
        cout << ans << "\n";
    } else {
        cout << "-1\n";
    }

    

    return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(1010);
    for(int i=0; i<n; i++){
        cin >> vec[i];
    }
    for(int i=n-1; i>0; i--){
        cout << vec[i] << " " ;
    }
    cout << vec[0] << endl;
    return 0;
}


Measured memory_bytes: 3120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long K = in.nextLong();
		long sum = 0;
		for(int i=1; i<=K; i++) {
			for(int j=1; j<=K; j++) {
				for(int k=1; k<=K; k++) {
					sum = sum + gcd(k, gcd(i,j));
				}
			}
		}
		
		System.out.println(sum);
		
	}
	
	public static int gcd(int x, int y) {
		if(y == 0) {
			return x;
		}
		return gcd(y, x%y);
	}
	
}


Measured memory_bytes: 35796
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long
#define MOD 1000000007

ll A[100][9];

bool valid(int n, int w) {
  bool ret = true;
  int prev = n % 2;
  n /= 2;
  for(int i=0; i<w-1; i++) {
    if((n % 2) * prev == 1) {
      ret = false;
      break;
    }
    prev = n % 2;
    n /= 2;
  }
  return ret;
}

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  A[0][0] = 1;
  for(int i=1; i<H+1; i++) {
    for(int j=0; j<pow(2,W-1); j++) {
      // init
      if(valid(j, W-1)) {
	int tmp = j;
	int prev = 0;
	for(int k=0; k<W; k++) {
	  if(prev == 0) {
	    if(tmp % 2 == 0) {
	      A[i][k] += A[i-1][k];
	      A[i][k] %= MOD;
	    } else {
	      A[i][k+1] += A[i-1][k];
	      A[i][k+1] %= MOD;
	    }
	  } else {
	    A[i][k-1] += A[i-1][k];
	    A[i][k-1] %= MOD;
	  }
	  prev = tmp % 2;
	  tmp /= 2;
	}
      }
    }
  }
  // for(int i=0; i<H+1; i++) {
  //   for(int j=0; j<W; j++) {
  //     cout << A[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  cout << A[H][K-1] % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main()
{
        int     n;
        int     c[500] = {};
        int     s[500] = {};
        int     f[500] = {};
        fscanf(stdin, "%d\n", &n);
        for(int i = 0;i < n - 1;i++)
        {
                fscanf(stdin, "%d %d %d", &c[i], &s[i], &f[i]);
        }
        for(int j = 0;j < n - 1;j++)
        {
                int t = 0;
                for(int i = j;i < n - 1;i++)
                {
                         if (t < s[i])
                         {
                                 t = s[i];
                         }
                         else
                         {
                                int w = t - s[i];
                                if (0 == (w % f[i]))
                                {
                                }
                                else
                                {
                                        t = (w / f[i] + 1) * f[i] + s[i];
                                }
                         }
                         t += c[i];
                }
                 printf("%d\n", t);
        }
        printf("0\n");
        return 0;

}

Measured memory_bytes: 128