akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int side(int up, int front, int n){
	int below = 7 - up;
	int back = 7 - front;
	int right = 0;
	int left;
	
	int kt = up;
	int kf, kr;
	switch(kt){
		case 1:
			kf = 2;
			kr = 3;
			break;
		case 2:
			kf = 6;
			kr = 3;
			break;
		case 3:
			kf = 6;
			kr = 5;
			break;
		case 4:
			kf = 6;
			kr = 2;
			break;
		case 5:
			kf = 6;
			kr = 4;
			break;
		case 6:
			kf = 5;
			kr = 3;
			break;
	}
	while(kf != front){
		int tmp = kr;
		kr = kf;
		kf = 7 - tmp;
	}
	right = kr;
	left = 7 - right;
	
	if(front == 6-n)
		return 3;
	else if(left == 6-n)
		return 0;
	else if(back == 6-n)
		return 1;
	else if(right == 6-n)
		return 2;

	return 4;
}

int main(){
	int field[199][199] = {0};
	int high[199][199] = {0};
	int dice[6] = {0};
	
	int n;
	int t,f;

	do{
		for(auto &h : high){
			for(int &h2 : h){
				h2 = 0;
			}
		}
		//cout << "\n";
		cin >> n;
		if(n == 0) break;
		for(int i=0;i<n;i++){
			cin >> t >> f;
			int keept = t, keepf = f;
			high[101][101]++;
			int x = 101, y = 101, nn = 0;
			while(nn < 3){
				int status = side(t, f, nn);
				int nowx = x;
				int nowy = y;
				//??¢??????????????????
				switch(status){
					case 0:
						y--;
						break;
					case 1:
						x++;
						break;
					case 2:
						y++;
						break;
					case 3:
						x--;
						break;
				}
				//??¢???????????????????????´??°??????break
				if(high[nowx][nowy] > 1 && high[x][y] < high[nowx][nowy]-1){
					high[nowx][nowy]--;
					high[x][y]++;
						if(status == 1)
							f = 7-t;
						else if(status == 3)
							f = t;
						t = nn + 1;
						nn = 0;
					//cout << t << " " << f << endl;
					if(high[x][y] == 1)
						break;
				//??¢????????????????????°???????????????????????????
				}else{
					nn++;
					x = nowx;
					y = nowy;
				}
			}
			/*cout << x << y << endl;
			cout << t << "\t" << f << endl;*/
			field[x][y] = t;
		}
		for(auto &cx : field){
			for(int &cy : cx){
				if(cy > 0)
					dice[cy-1]++;
					cy = 0;
			}
		}

		int dicecount = 0;
		for(int &di : dice){
			if(dicecount < 5)
				cout << di << " ";
			else
				cout << di;
			dicecount++;
			di = 0;
		}
		cout << "\n";
	}while(n > 0);

	return 0;
}

Measured memory_bytes: 3404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main();
	}
	
	public Main(){
		doIt();
	}
	
	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		UnionFind uf = new UnionFind(n);
		for(int i = 0; i < q; i++){
			int op = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			if(op ==0) uf.unite(x, y);
			else{
				int ans = 0;
				if(uf.same(x,y)){
					ans = 1;
				}
				System.out.println(ans);
			}
		}
	}
}

class UnionFind{
	int par[]; //???
	int rank[]; //??¨?????±???
	
	public UnionFind(int n){
		rank = new int[n];
		par = new int[n];
		for(int i = 0; i < n; i++){
			par[i] = i;
		}	
	}
	
	//??¨??????????±???????
	int find(int x){
		if(par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	
	//x??¨y????±??????????????????????
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y)return;
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	
	boolean same(int x, int y){
		return find(x) == find(y);
	}
}

Measured memory_bytes: 95156
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> x, vector<ll> y) {
  int minpos = 0, maxpos = 0;
  REP(i,N) {
    if (x[i] > y[i]) swap(x[i], y[i]);
    if (x[i] < x[minpos]) minpos = i;
    if (y[i] > y[maxpos]) maxpos = i;
  }
  ll red = *max_element(ALL(x));
  ll blue = *min_element(ALL(y));
  ll res = (red - x[minpos]) * (y[maxpos] - blue);
  if (minpos == maxpos) { cout << res << endl; return; }
  vector<pair<ll,int>> vec;
  REP(i,N) {
    if (i != minpos) vec.emplace_back(x[i], i);
    if (i != maxpos) vec.emplace_back(y[i], i);
  }
  sort(ALL(vec));
  ll min_dist = 1e18;
  int lb = 0, ub = 0;
  map<ll,int> mapsto;
  for (;;) {
    // cout << lb << " " << ub << endl;
    if (int(mapsto.size()) == N) {
      chmin(min_dist, vec[ub-1].first - vec[lb].first);
      mapsto[vec[lb].second] -= 1;
      if (mapsto[vec[lb].second] == 0) {
        auto it = mapsto.lower_bound(vec[lb].second);
        mapsto.erase(it);
      }
      ++lb;
    }
    else {
      if (ub == int(vec.size())) break;
      mapsto[vec[ub].second] += 1;
      ++ub;
    }
  }
  // cout << min_dist << endl;
  chmin(res, (y[maxpos] - x[minpos]) * min_dist);
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> y(N-1+1);
	vector<ll> x(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	}
	solve(N, x, y);
	return 0;
}


Measured memory_bytes: 27112
#include <bits/stdc++.h> 
using namespace std;
std::queue<long long> q;
int k;

int main() {
	cin >> k;
    for (int i = 1; i <= 9; ++i)    q.push(i);
    for (int i = 1; i < k; ++i) {
        long long a = q.front();
        int dig = a % 10;
        q.pop();
        if (dig != 0)   q.push(a * 10 + dig - 1);
        q.push(a * 10 + dig);
        if (dig != 9)   q.push(a * 10 + dig + 1);
    }
    printf("%lld\n", q.front());
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    long int K, X;

    cin >> K >> X;

    if (K*500 >= X)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int N, C[500], S[500], F[500];
int main() {
  scanf("%d", &N);
  for(int i = 1; i < N; i++) {
    scanf("%d %d %d", &C[i], &S[i], &F[i]);
  }
  for(int i = 1; i < N; i++) {
    int ans = 0;
    for(int j = i; j < N; j++) {
      int dx = ans-S[j];
      if(dx > 0) {
        if(dx%F[j]) ans += F[j]-dx%F[j]+C[j];
        else ans += C[j];
      } else {
        ans += -dx+C[j];
      }
    }
    printf("%d\n", ans);
  }
  printf("%d\n", 0);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

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

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

static const int N=1000;

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m= X.size();
    int n=Y.size();
    int maxl = 0;
    X=' '+X;
    Y=' '+Y;
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int j=0;j<=m;j++) c[0][j]=0;
    
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(X[i]==Y[j]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=max(c[i-1][j],c[i][j-1]);
            }
            maxl=max(maxl,c[i][j]);
        }
    }
    
    return maxl;
}

int main(){
    string s1, s2;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        cout<<lcs(s1,s2)<<endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

ll store[2001];

ll dp(int sum) {
	if (sum == 0) return 1;
	if (sum <= 2) return 0;
	if (sum <= 5) return 1;
	if (store[sum] != -1) return store[sum];

	ll res = 0;
	for (int i = 3; i <= sum; ++i)
	{
		res += dp(sum - i);
		res %= MOD;
	}
	return store[sum] = res;
}

int main() {
	fast();
	int s;
	cin >> s;
	mems(store);
	cout << dp(s) << nl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    string S;
    cin >> S;

    int res = 0;
    for (int i = 0; (i < S.size()); ++i) {
        if (S[i] == '+')
            ++res;
        else
            --res;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	  public static void main(String args[]){
	 Scanner scanner = new Scanner(System.in);

int k=scanner.nextInt();
int a=scanner.nextInt();
int b=scanner.nextInt();

for(int i=a;i<=b;i++) {
	if(i%k==0) {
		System.out.println("OK");
		break;
	}
	if(i==b
			) {
		System.out.println("NG");
		break;
	}

}
}
	  }

Measured memory_bytes: 35668
n = int(input())
a = list(map(int, input().split()))

b = [0] * (n+1)
for i in reversed(range(1, n+1)):
    bi = 0
    for j in range(2, n//i + 1):
        bi += b[i*j]
    bi %= 2

    if bi != a[i-1]:
        b[i] = 1
    else:
        b[i] = 0

b_idx = [str(i) for i in range(1, n+1) if b[i] == 1]
m = len(b_idx)
print(m)
if m > 0:
    print(' '.join(b_idx))


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

int N, M;
vector<int> s, t;
vector<int> G[100000];
int used[100000];

void dfs1(int v) {
	s.push_back(v);
	used[v] = 1;
	for (auto to : G[v]) {
		if (!used[to]) {
			dfs1(to);
			break;
		}
	}
}

void dfs2(int v) {
	t.push_back(v);
	used[v] = 1;
	for (auto to : G[v]) {
		if (!used[to]) {
			dfs2(to);
			break;
		}
	}
}

int main()
{
	cin >> N >> M;
	for (int i = 0, a, b; i < M; i++) {
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	dfs1(0);
	dfs2(0);
	reverse(t.begin(), t.end());
	t.pop_back();
	cout << s.size() + t.size() << endl;
	for (int v : t) {
		cout << v + 1 << ' ';
	}
	for (int i = 0; i < s.size() - 1; i++) {
		cout << s[i] + 1 << ' ';
	}
	cout << s.back() + 1 << endl;
	return 0;
}


Measured memory_bytes: 9976
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		System.out.println(s.substring(0, 4) + " " + s.substring(4));
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22740
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool>snks(N, false);

    for (int i=0; i<K; i++){
        int di;
        cin >> di;
        vector<int>As(di);
        for (int j=0; j<di; j++)cin >> As[j];
        for (int j=0; j<di; j++)snks[As[j]-1] = true;
        
    }
    int cnt = 0;
    for (int i=0; i<N; i++){
        if (snks[i] == false)cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 3632
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: AmShZ6
 * Time: 2020-05-30 17:02:30
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 1e14;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , ans , A[MAXN] , B[MAXN];

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

    cin >> n;
    for(int i = 0 ; i <= n ; i++)   cin >> A[i];
    B[0] = 1;
    for(int i = 1 ; i <= n ; i++){
        B[i] = (B[i - 1] - A[i - 1]) * 2;
        B[i] = min(B[i] , INF);
    }
    if(A[n] > B[n]) return cout << -1 << endl , 0;
    for(int i = n ; i >= 1 ; i--){
        ans += A[i];
        A[i - 1] += min(A[i] , B[i - 1] - A[i - 1]);
    }
    if(A[0] != 1)   return cout << -1 << endl , 0;
    cout << ans + 1 << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 5224
from fractions import gcd
 
n,*a = map(int, open(0).read().split())
 
rs, ls = [0], [0]
for i in range(n-1):
  rs.append(gcd(rs[i], a[i]))
  ls.append(gcd(ls[i], a[-i-1]))
 
print(max(gcd(r, l) for r, l in zip(rs, ls[::-1])))

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

int main(){
 int H,W;
 while(true){
  cin >> H >> W;
  if(H == 0 && W == 0) break;
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    if((i+j)%2 == 0) cout <<"#";
    else cout << ".";
   }
  cout << "\n";
  }
 cout << "\n";
 }
}


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

using namespace std;

string a,b="CF";
int len;

int main()
{
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
    	if(a[i]==b[len])
		{
            len++;
            if(len==2)
            {
            	break;
            }
        }
    } 
    if(len==2) 
	{
		cout<<"Yes"<<endl;
	}
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<vector>

int main(){
	long long int a,b,k;
	std::cin>>a>>b>>k;

	if (a > k) {
		std::cout<<a-k<< " " << b<<std::endl;
		exit(0);
	}
	else if (a + b > k) {
		std::cout<<0<<" "<<a+b-k<<std::endl;
		exit(0);
	}
	else {
		std::cout<<0<< " " << 0<<std::endl;
		exit(0);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int br[10], ar[10], a, b, c, n;

int f() {
    int la = 0, lb = 0, lc = 0, sum = 0;
    int p[3] = {0};
    for(int i = 0; i < n; ++i) {
        if(br[i] == 0)
            continue;
        p[br[i] - 1] = 1;
    }
    for(int i = 0; i < 3; ++i) {
        if(!p[i])
            return 1e9;
    }
    for(int i = 0; i < n; ++i) {
        if(br[i] == 1) {
            la += ar[i];
            sum += 10;
        } else if(br[i] == 2) {
            lb += ar[i];
            sum += 10;
        } else if(br[i] == 3) {
            lc += ar[i];
            sum += 10;
        }
    }
    return abs(la - a) + abs(lb - b) + abs(lc - c) + sum - 30;
}

int main() {
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; ++i)
        cin >> ar[i];
    int mn = 999999999;
    while(br[9] != 1) {
        br[0] += 1;
        for(int i = 1; i < 10; ++i)
            br[i] += br[i - 1] / 4, br[i - 1] %= 4;
        mn = min(mn, f());
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define SE -1e10
#define EE 2e10
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int a,b,q;
  cin>>a>>b>>q;
  vector<long>s(a),t(b);
  for(int i=0;i<a;i++)
  {
    cin>>s[i];
  }
  for(int i=0;i<b;i++)
  {
    cin>>t[i];
  }
  s.push_back(SE);
  s.push_back(EE);
  t.push_back(SE);
  t.push_back(EE);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  for(int i=0;i<q;i++)
  {
    long x;
    cin>>x;
    auto si=lower_bound(s.begin(), s.end(), x);
    auto ti=lower_bound(t.begin(), t.end(), x);
    long res;
    res=min(x-min(*(si-1),*(ti-1)),max(*si,*ti)-x);
    res=min(res,*ti-*(si-1)+min(*ti-x,x-*(si-1)));
    res=min(res,*si-*(ti-1)+min(*si-x,x-*(ti-1)));

    cout<<res<<"\n";




  }

  return 0;

}


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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second


int main(){
    ll n; cin >> n;
    ll cnt = 9;
    queue<ll> que;
    vector<ll> v;
    for(int i = 1; i < 10; i++) {
        que.push(i);
        v.PB(i);
    }

    while(cnt <= n){
        ll a = que.front();
        ll b = a % 10;
        if(b == 0){
            que.push(a*10);
            que.push(a*10+1);
            v.PB(a*10);
            v.PB(a*10+1);
            cnt += 2;
        }else if(b == 9){
            que.push(a*10+8);
            que.push(a*10+9);
            v.PB(a*10+8);
            v.PB(a*10+9);
            cnt += 2;
        }else{
            que.push(a*10+b-1);
            que.push(a*10+b);
            que.push(a*10+b+1);
            v.PB(a*10+b-1);
            v.PB(a*10+b);
            v.PB(a*10+b+1);
            cnt += 3;
        }
        que.pop();
    }
    cout << v[n-1] << endl;
    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5&&b==5&&c==7){
    cout<<"YES"<<endl;
  }
  else if(a==5&&b==7&&c==5){
    cout<<"YES"<<endl;
  }
  else if(a==7&&b==5&&c==5){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n,m,q;
  cin >> n >> m >> q;
  vll a(q),b(q),c(q),d(q);
  rep(i,0,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
     --a[i];
     --b[i];
  }
  vll num(n+m-1,0);
  rep(i,0,m-1) num[n+m-2-i]=1;
  
  ll ans=0;
  do{
   vll vec(n,0);
   ll index=0;
   ll cnt=1;
   for(auto n:num){
    if(n) cnt++;
    else vec[index++]=cnt; 
   }
    ll sum=0;
   rep(i,0,q){
    if(vec[b[i]]-vec[a[i]]==c[i]) sum+=d[i]; 
   }
    chmax(ans,sum);
    
  }while(next_permutation(all(num)));
  
  cout << ans << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3640
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
/* 
struct edge{
	int to, next;
}e[200005];
int head[100005], tot, n, k, x, y, mod = 1000000007;
void add(int u, int v)
{
	e[tot].to = v, e[tot].next = head[u],  head[u] = tot++;
} */ 
vector<P> gt[305];
int mod = 1000000007, dp[305][305][305], n, m, ans;
bool judge(int a, int b, int c, int r)
{
	for (int i = 0; i < gt[r].size(); i++)
	{
		int ct = 0;
		if (a >= gt[r][i].first)
			ct++;
		if (b >= gt[r][i].first)
			ct++;
		if (c >= gt[r][i].first)
			ct++;
		if (ct != gt[r][i].second)
			return false;
	}
	return true;
}
signed main(){
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 0; i <= 300; i++)	gt[i].clear();
		ans = 0;
		for (int i = 0; i < m; i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			gt[b].push_back(P(a, c));
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for (int i = 0; i <= n; i++)
		{
			for (int j = 0; j <= n; j++)
			{
				for (int k = 0; k <= n; k++)
				{
					int  x = max(i, max(j, k)) + 1;
					if (judge(i, j, k, x - 1) && dp[i][j][k])
					{
						dp[x][j][k] = (dp[x][j][k] + dp[i][j][k]) % mod;
						dp[i][x][k] = (dp[i][x][k] + dp[i][j][k]) % mod;
						dp[i][j][x] = (dp[i][j][x] + dp[i][j][k]) % mod;
					}
					else
					{
						dp[i][j][k] = 0;
					}
					if (x == n + 1)	ans = (ans + dp[i][j][k]) % mod;
				}
			}
		}
		printf("%d\n", ans);
	}
}


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

using lint = long long;

int main(){
    lint X, Y;
    lint ans = 0;
    cin >> X >> Y;
    lint Xdash = X;
    while(Xdash <= Y){
        ans++;
        Xdash *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var x = ss.Next<int>();
		Console.WriteLine(x*x*x);

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}

public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9904
#include <cstdio>
#include <cstring>
#include <cstdlib>

char s[8192];

int main() {
  int N;
  int K;
  int d[100] = {0};
  int A[100][100] = {{0}};
  int h[100] = {0};

  fgets(s, sizeof(s), stdin);
  sscanf(s, " %d %d", &N, &K);
  for (int i = 0; i < K; ++i) {
    fgets(s, sizeof(s), stdin);
    sscanf(s, " %d", &d[i]);
    for (int j = 0; j < d[i]; ++j) {
      scanf(" %d", &A[i][j]);
      h[A[i][j] - 1] = 1;
    }
    fgets(s, sizeof(s), stdin);
  }

  int result = 0;
  for (int i = 0; i < N; i++) {
    result += (1 - h[i]);
  }

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

Measured memory_bytes: 1812
// AtCoder Grand Contest 031 C
// Code By GNAQ (copy: ninja7|4604302)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<iterator>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef ostream_iterator<int> os_iter_int;

int n,a,b,nn;
vector<int> ans;


template<typename inp_t>
void readx(inp_t& x)
{
	x=0; int k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

int Bits(int val)
{
	int ret=0;
	while (val)
	{
		ret+=val&1;
		val>>=1;
	}
	return ret;
}

int lowbit(int x)
{
	return x&(-x);
}

// 这tm就是个分治
void Solve(int step,int na,int nb,int mask)
{
	if (step==1) 
	{
		ans.push_back(na);
		ans.push_back(nb);
		return;
	}
	
	int nowbit= lowbit( mask&(na^nb) );
	mask^=nowbit;
	int nc=na;
	for (int i=0;i<n;i++) if (mask&(1<<i))
	{
		nc^=1<<i;
		break;
	}
	
	Solve(step-1,na,nc,mask);
	nc^=nowbit;
	Solve(step-1,nc,nb,mask);
}

int main()
{	
	readx(n); readx(a); readx(b);
	nn=(1<<n);
	
	int differ=0;
	for (int i=0;i<n;i++)
		if ( (a>>i)%2 != (b>>i)%2 ) 
			differ++;
	if (!(differ%2)) { printf("NO\n"); return 0; }
	
	// Logic by alphaGem
	// implemented by ninja7 in (easy) DFS
	// more than long loops
	Solve(n,a,b,(1<<n)-1);
	
	printf("YES\n");
	for (auto v:ans) printf("%d ",v);
	
}

Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 1)cout << "Hello World" << endl;
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    if(n % 2 == 0){
        int num = ((n-2)*n)/2;
        cout << num << endl;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                if(i + j + 2 != n+1) cout << i+1 << ' ' << j+1 << endl;
            }
        }
    }else{
        int num = ((n-1)*(n-1))/2;
        cout << num << endl;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                if(i + j + 2!= n) cout << i+1 << ' ' << j+1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<int>

using namespace std;
using ll = long long;
using veci = vec(int);
using vecll = vec(ll);

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

    int N, K;

    cin >> N >> K;
    string S;
    cin >> S;

    veci vv;
    if (S[0]=='0') vv.push_back(0);

    rep(i,0,S.size()-1) {
        if (i==0) vv.push_back(1);
        else if (S[i]==S[i-1]) vv.back()++;
        else vv.push_back(1);
    }

    int ans=0;
    int acc=0;
    veci vac;
    vv.push_back(0);
    vv.push_back(0);
    vv.push_back(0);
    vv.push_back(0);

    rep(i,0,vv.size()-1) {
        acc += vv[i];
        vac.push_back(acc);
        if (i%2==0) {
            int j = i - K*2-1;
            if (j<0) ans=acc; else ans = max(ans, acc - vac[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint ans = 0;
  lint cnt = 1;
  lint h; cin >> h;
  while(1) {
    ans += cnt;
    if(h == 1) break;
    h /= 2;
    cnt *= 2;
  }
  cout << ans << endl;
  return 0;
}


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

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

	int n = s.size();

	vector<vector<int>> dp(n + 1, vector<int>(2, 0));

	dp[1][0] = 1;

	for (int i = 1; i < n; i++)
	{
		dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + 1);
		if (s[i - 1] != s[i])
		{
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + 1);
		}

		dp[i + 1][1] = max(dp[i + 1][1], dp[i - 1][0] + 1);
		if (i - 3 < 0 || s.substr(i - 3, 2) != s.substr(i - 1, 2))
		{
			dp[i + 1][1] = max(dp[i + 1][1], dp[i - 1][1] + 1);
		}
	}

	cout << max(dp[n][0], dp[n][1]) << endl;

	return 0;
}

Measured memory_bytes: 14456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	if (a+b>c+d){
      cout << "Left";
    }
  	if (a+b==c+d){
      cout << "Balanced";
    }
  	if (a+b<c+d){
      cout << "Right";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Mod 1000000007
#define Val(x) (((long long)x) % Mod)
#define maxn 5005
using namespace std;
int dp[maxn][maxn];
int Pow(int a,int n){
	int ret = 1;
	int base = a;
	while(n) {
		if(n&1)		ret = Val(ret*base);
		base = Val(base*base);
		n >>= 1;
	}	
	return ret;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	dp[0][0] = 1;
	for(int i=1;i<=5000;i++) {
		dp[i][0] = Val(dp[i-1][0] + dp[i-1][1]);
		for(int j=1;j<=i;j++)
			dp[i][j] = Val(dp[i-1][j+1]+dp[i-1][j-1]+dp[i-1][j-1]);
	}
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int m = (int)s.size();
	
	int ans = Val(dp[n][m]);
	
	int tem = Pow(2,m);
	ans = Val(ans*Pow(tem,Mod-2));
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 96384
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int n;
  cin >> n;
  vs s(n);
  map<string, int> memo;
  int c = 0;
  rep(i, n) {
    cin >> s[i];
    if(memo.count(s[i]) == 0){
      memo[s[i]] = 1;
      c++;
    }
  }
  cout << c << endl;
}


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

int main(){
	int m1, d1;
	cin >> m1 >> d1;
	int m2, d2;
	cin >> m2 >> d2;
	if(m2 - m1 > 0 && d2 - d1 < 0){
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 3556
list = list(map(int, input().split()))

temp = 0

for i in range(len(list)):
    for j in range(len(list)-1, i, -1):
        if list[j] < list[j-1]:
            temp = list[j]
            list[j] = list[j-1]
            list[j-1] = temp
    
print(list[0], list[1], list[2])



Measured memory_bytes: 5592
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    bool any_odd = false;
    for (int i = 0; i < n; i++)
    {
        int64_t v;
        cin >> v;
        if (v % 2 == 1)
        {
            any_odd = true;
        }
    }
    cout << (any_odd ? "first" : "second");
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
const int maxn=1e6;
int main(){
	int a,b,x;
	cin>>a>>b>>x;
	if(x-a>b||x<a)printf("NO");
	else printf("YES");
	printf("\n");

}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vl v(n), sp(n);
    for (int i = 0; i < n; ++i){
    	cin >> v[i];
    	if(!i) sp[i] = v[i];
    	else{ 
    		sp[i] = (sp[i-1]+v[i])%prime;
    	}
    }
    ll ans = 0;
    for (int i = 0; i < n-1; ++i){
    	ans += (v[i]*(sp[n-1]+prime-sp[i])%prime)%prime;
    	ans%=prime;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6360
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef pair<int, int> P;

bool comp(P a, P b) {
	if(a.second < b.second) {
		return false;
	} else if(a.second > b.second) {
		return true;
	} else {
		if(a.first < b.first) {
			return true;
		} else {
			return false;
		}
	}
	return false;
}

int main(void) {
	int n, m, tmp;
	vector<P> count;
	vector<int> precount;
	int i, j;

	while(true) {
		cin >> n >> m;
		if((n == 0 && m == 0) || cin.eof()) { break; }
		precount.clear();
		for(i = 0; i < m; i++) { precount.push_back(0); }
		for(i = 0; i < n; i++) {
			for(j = 0; j < m; j++) {
				cin >> tmp;
				precount[j] += tmp;
			}
		}

		count.clear();
		for(i = 0; i < m; i++) {
			count.push_back(P(i+1, precount[i]));
		}
		sort(count.begin(), count.end(), comp);

		for(i = 0; i < m; i++) {
			cout << count[i].first << (i+1<m?" ":"");
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 912
#include<stdio.h>
#include<string.h>
//20000桁のマージソート(1単語10文字以下)
char c[101];
int sort(int a,int b,char s[101]){
  if(a==b)
    return 0;
  sort(a,(a+b)/2,s);
  sort((a+b)/2+1,b,s);
  int i=a,j=(a+b)/2+1,k=a;
  while(k<=b){
    if(i<(a+b)/2+1 && j<b+1){
      if(s[i]<s[j]){
        c[k]=s[i];
        i++;
      }
      else{
        c[k]=s[j];
        j++;
      }
    }
    else if(j>b){
      c[k]=s[i];
      i++;
    }
    else{
      c[k]=s[j];
      j++;
    }
    k++;
  }
  for(i=a;i<=b;i++)
    s[i]=c[i];
  return 0;
}

int main(){
  char s[101],t[101];
  scanf("%s%*c%s",s,t);
  int slen=strlen(s);
  int tlen=strlen(t);
  int i;
  sort(0,slen-1,s);
  sort(0,tlen-1,t);
  for(i=0;i<slen;i++){
    if(s[i]<t[tlen-1-i]){
      puts("Yes");
      return 0;
    }
    else if(s[i]>t[tlen-1-i]){
      puts("No");
      return 0;
    }
  }
  if(slen==tlen)
    puts("No");
  else
    puts("Yes");
  return 0;
}


Measured memory_bytes: 128
import itertools
 
N, M, R = map(int, input().split())
r = [int(x) - 1 for x in input().split()]
 
dist = [[float('inf')] * N for _ in range(N)]
for _ in range(M):
	a, b, c = map(int, input().split())
	a -= 1
	b -= 1
	dist[a][b] = dist[b][a] = c
 
for k in range(N):
	for i in range(N):
		for j in range(N):
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
 
ans = float('inf')
k = list(itertools.permutations(r))
for i in k:
	sumDist = 0
	for j in range(len(i) - 1):
		sumDist += dist[i[j]][i[j+1]]
	ans = min(ans, sumDist)
print(ans)

Measured memory_bytes: 78808
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string str;
    cin>>str;
    int n = (int)str.size();
    int count = 0;
    for(int i=0;i<n/2;++i){
        if(str[i] != str[n-i-1])count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
n=int(input())
List1=[q*4,h*2,s]
List2=[q*8,h*4,s*2,d]
if (n%2==0):
  ans=n*min(List2)//2
  print(ans)
else:
  ans=(n-1)*min(List2)//2
  ans+=min(List1)
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	vector <int> v;
	int a, b, c;
	cin >> a >> b >> c;
	v.push_back(a); v.push_back(b); v.push_back(c);
	sort(v.begin(), v.end());
	print(v[2] * 10 + v[1] + v[0]);


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
    double a,b,c,C,radC;
    scanf("%lf %lf %lf",&a,&b,&C);
    radC=C*M_PI/180;
    printf("%.8lf %.8lf %.8lf",a*b*sin(radC)/2.0,a+b+sqrt(a*a+b*b-2*a*b*cos(radC)),b*sin(radC));
    return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll ans=0;
ll n;

void dfs(ll a,ll t,ll f,ll s){
  if(a>n) return;
  if(t && f && s) ans++;
  dfs(a*10+3,1,f,s);
  dfs(a*10+5,t,1,s);
  dfs(a*10+7,t,f,1);
}

int main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    long long int ryu[87] = {}, k;
    ryu[0] = 2;
    ryu[1] = 1;
    for (int i = 2; i < 87;i++){
        ryu[i] = ryu[i - 1] + ryu[i - 2];
    }
    cin >> k;
    cout << ryu[k] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	int ans = INF;
	vector<int> dp(20010,INF);
	dp[0] = 0;
	for (int i = 1; i < 20010; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= a[j]) {
				chmin(dp[i], dp[i - a[j]] + b[j]);
			}
		}
	}
	for (int i = h; i < 20010; i++) chmin(ans, dp[i]);
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int const INF = 1001001001;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> to[100005];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;    --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> d(n,INF);
    vector<int> pre(n,-1);
    queue<int> q;
    d[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int u : to[v]){
            if(d[u]!=INF)
                continue;
            d[u] = d[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    puts("Yes");
    for(int i=1;i<n;i++){
        cout << pre[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10616
#ifndef LOCAL
#pragma GCC optimize("O2")
#endif
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int A, B;
    cin >> A >>B;
    int count =0;
    int n=1;
    while(1+(A-1)*(n-1) < B){
       count++;
       n++;
    }
    cout << count;    

}

Measured memory_bytes: 256
input()
slist = map(int, raw_input().split())
input()
tlist = map(int, raw_input().split())

def func(v, low, high):

    # print "l h = %d %d" % (low, high)
    if low > high:
        return 0

    mid = (low + high)/2
    
    # print "mid %d" % mid
    
    if mid >= len(slist):
        # print "test1"
        return 0
    
    if v > slist[mid]:
        if low == high:
            # print "test2"
            return 0
        # print "test3"
        return func(v, mid+1, high)
        
    elif v == slist[mid]:
        # print "test4"
        return 1
    else:
        if low == high:
            # print "test5"
            return 0

        # print "test6 %d %d" % (v, slist[mid])
        return func(v, low, mid-1)

count = 0
for t in tlist:
    count += func(t, 0, len(slist)-1)
print count

Measured memory_bytes: 14744
#include <iostream>

using namespace std;

int main()
{
    int n, l; cin >> n >> l;
    int sum = n * (n - 1) / 2 + n * l;
    if(l > 0) sum -= l;
    else if(l <= -n) sum -= n + l - 1;
    cout << sum; return 0;
}


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

#define int long long

const double pi=3.14159265359;

int32_t main()
{

  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double a1=((m*pi)/30.0);
  double a2=((h*pi)/(6.0))+((pi*m)/360.0);

  double ans=sqrt((a*a)+(b*b)-(2LL*a*b*cos(a1-a2)));

  printf("%0.18f",ans);

  return 0;
}


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

using namespace std;

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

  long long l[n];
  for (int i = 0; i < n; ++i) cin >> l[i];
  sort(l, l + n);

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (l[i] == l[j]) continue;
      for (int k = j + 1; k < n; ++k) {
        if (l[i] == l[k] || l[j] == l[k]) continue;
        if (l[i] + l[j] <= l[k]) break;
        cnt++;
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

const int INF = 2100100100;


int main(){
  string s,t;cin>>s>>t;
  int ls=s.size();
  int lt=t.size();
  int best=100000;
  //cout<<ls<<lt<<endl;
  for(int i=0;i<ls-lt+1;i++){
    //cout<<i<<endl;
    int tmp=0;
    for(int j=0;j<lt;j++){
      if(s[i+j]!=t[j]){
        tmp++;
      }
    }
    if(tmp<best){
      best=tmp;
    }
  }
  cout<<best<<endl;
}

Measured memory_bytes: 3196
input = gets.chomp
a = input.split(" ")[0].to_i
b = input.split(" ")[1].to_i

if -1000 <= a && b <= 1000
  if a < b
    puts "a < b"
  elsif a > b
    puts "a > b"
  else
    puts "a == b"
  end
else
  return
end



Measured memory_bytes: 6852
N,M = map(int, input().split())

AC = [0] * (N+1)
pl = [0] * (N+1)
cole = 0
pena = 0
for target_list in range(M):
    ans = input().split()
    problem = int(ans[0])
    result = ans[1]

    if AC[problem] == 0 and result == 'WA':
        pl[problem] += 1
    elif AC[problem] == 0 and result == 'AC':
        pena += pl[problem]
        cole += 1
        AC[problem] = 1

print(cole, pena)



Measured memory_bytes: 10388