akhauriyash/Code-Regression huggingface dataset:
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    static String P = "";
    static String Q = "";
    static int countP = 0;
    static int countQ = 0;
    static boolean isP = false;
    static boolean isQ = false;
    public static void main(String[] args) {
        int N = nextInt();

        String T = "";

        for(int i=0; i<N; i++){
            P += next();
            T += i+1;
        }
        for(int i=0; i<N; i++){
            Q += next();
        }

        permutation(T, "");
        println(Math.abs(countP-countQ));
    }

    public static void permutation(String q, String ans){
        if(isP && isQ) return;
        // Base Case
        if(q.length() <= 1) {
           if(!isP)countP++;
           if(!isQ)countQ++;
           if(P.equals(ans + q)){
               isP = true;
           }
           if(Q.equals(ans + q)){
               isQ = true;
           }
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
                if(isP && isQ) return;
            }
        }
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 42320
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
string s;
signed main(){
    cin>>s;
    int l=s.size();
    rep(i,l-1){
        for(int j=i;j<l;j++){
            string t=s.substr(0,i)+s.substr(j);
            if(t=="keyence"){
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, m, k = read_int_list()
    for i in range(n+1):
        for j in range(m+1):
            if i * j + (n - i) * (m - j) == k:
                return 'Yes'
    return 'No'


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
  int N,L; cin >> N >> L;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  
  sort(s.begin(),s.end());
  
  string ans;
  for (int i = 0; i < N; i++) ans += s[i];
  
  cout << ans << endl;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x;
vi p;

signed main() {
	cin >> x;
	p.pb(1);
	repst(i,2,x) repst(j,2,10) {
		int t = pow(i,j);
		if (t>x) break;
		else p.pb(t);
	}
	sort(all(p));
	cout << p[p.size()-1] << ln;
}

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

int main(){
	int n; cin >> n;
	int ans = 0;
	for(int i = 0; i < n; ++i){
		int l, r; cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
	int w;
	int h;
	int n;
	int[] x;
	int[] y;
	int[] a;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		w = sc.nextInt();
		h = sc.nextInt();
		n = sc.nextInt();
		x = new int[n];
		y = new int[n];
		a = new int[n];
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
	}
	void solve(){
		int sx = 0,sy = 0;
		int gx = w,gy = h;
		for(int i=0;i<n;i++){
			switch(a[i]){
			case 1:
				sx = Math.max(sx, x[i]);
				break;
			case 2:
				gx = Math.min(gx, x[i]);
				break;
			case 3:
				sy = Math.max(sy, y[i]);
				break;
			case 4:
				gy = Math.min(gy, y[i]);
				break;
			}
		}
		System.out.println((gx-sx)>0&&(gy-sy)>0?(gx-sx)*(gy-sy):0);
	}
}


Measured memory_bytes: 23380
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
d=[]
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
    d+=(a-1,b-1),
s=[(0,0)]
f=[1]+[0]*n
dic=dict()
while s:
    v,color=s.pop()
    i=0
    for w in e[v]:
        if f[w]:continue
        f[w]=1
        i+=1
        if i==color:i+=1
        s+=(w,i),
        dic[v,w]=i
ans=[]
for a,b in d:
    if (a,b)in dic:
        ans+=dic[a,b],
    else:
        ans+=dic[b,a],
print(max(ans))
for t in ans:print(t)

Measured memory_bytes: 61712
import java.util.*;
import java.lang.*;
import java.io.*;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    String input1 = scanner.next();
    String input2 = scanner.next();
    String input3 = scanner.next();
 
int N = Integer.parseInt(input1);
int A = Integer.parseInt(input2);
int B = Integer.parseInt(input3);

int max = 0;
int min = 0;

if(A>B){
max = B;
min = A - (N - B);
}else{
max = A;
min = B - (N - A);
}

if(min<0){
min = 0;
}

    System.out.print(max + " " + min);
    scanner.close();
  }
}

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

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

int main(int argc, char const *argv[])
{
	int h,w;
	cin>>h>>w;
	char s[h][w];
	int cnt=0;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>s[i][j];
			if (s[i][j]=='#')
			{
				++cnt;
			}
		}
	}
	int memo[h][w]={};
	queue<pair<int,int>> que;
	memo[0][0]=1;
	que.push({0,0});
	while (!que.empty())
	{
		auto now=que.front();que.pop();
		for (int i = 0; i < 4; ++i)
		{
			int nx=now.first+dx[i],ny=now.second+dy[i];
			if (0<=nx&&nx<h&&0<=ny&&ny<w&&memo[nx][ny]==0&&s[nx][ny]=='.')
			{
				memo[nx][ny]=memo[now.first][now.second]+1;
				que.push({nx,ny});
			}
		}
	}
	if (memo[h-1][w-1]==0)
	{
		cout<<"-1\n";
		return 0;
	}
	else
	{
		cout<<h*w-memo[h-1][w-1]-cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<array>
int a[100001], b[100001],v[100001], e[100001][4] ;
int pathcheck(int a, int b, int vv, int from);
using namespace std;
int main() {
	
	/*int n;
	int b[101], c[101];
	cin >> n;
	int i,j,k;
	for (i = 1; i <= n; i++) {
		cin >> b[i];
	}
	int maxa, maxb;

	for (i = n; i >= 1; i--) {
		for (j = i; j >= 1; j--) {
			if (b[j] > j) {
				cout << -1;
				return 0;
			}
			else if (b[j] == j) {
				c[i] = j;
				for (k = j; k < n; k++) {
					b[k] = b[k + 1];
				}
				break;
			}
		}
	}
	for (i = 1; i <= n; i++) {
		cout << c[i];
		cout << '\n';
	}
	return 0;*/
	//B
	/*int n,m;
	cin >> n;
	int i, j;
	if (n % 2 == 0) {
		m = (n * (n - 1)) / 2 - n / 2;
		cout << m;
		cout << '\n';
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				if ((i + j) == n + 1) {

				}
				else {
					cout << i;
					cout << ' ';
					cout << j;
					cout << '\n';
				}
			}
		}
	}
	else {
		//n%2 == 1;
		m = (n * (n - 1)) / 2 - (n-1) / 2;
		cout << m;
		cout << '\n';
		for (i = 1; i <= n-1; i++) {
			for (j = i + 1; j <= n-1; j++) {
				if ((i + j) == n) {

				}
				else {
					cout << i;
					cout << ' ';
					cout << j;
					cout << '\n';
				}
			}
			cout << i;
			cout << ' ';
			cout << n;
			cout << '\n';
		}
		
	}

	return 0;
	*/
	//C
	int n, m;
	cin >> n >> m;
	int a[100001], b[100001];
	int i,j;
	for (i = 0; i <= n; i++) {
		for (j = 0; j < 4; j++) {
			e[i][j] = -1;
		}
	}
	for (i = 0; i <= n; i++) {
		v[i] = 0;
	}
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		v[a[i]]++;
		v[b[i]]++;
		for (j = 0; j < 4; j++) {
			if (e[a[i]][j] == -1) {
				e[a[i]][j] = b[i];
				break;
			}
		}
		for (j = 0; j < 4; j++) {
			if (e[b[i]][j] == -1) {
				e[b[i]][j] = a[i];
				break;
			}
		}
	}
	int vcounter = 0;
	int vcounter4 = 0;
	int v4[2] = { -1, -1 };
	for (i = 1; i <= n; i++) {
		if (v[i] % 2 == 1) {
			cout << "No\n";
			return 0;
		}
		//else if (v[i] > 6) {
		//	cout << "No\n";
		//	return 0;
		//}
		else {
			vcounter = vcounter + v[i];
			if (v[i] == 4) {
				vcounter4++;
				if (v4[0] == -1) {
					v4[0] = i;
				}
				else {
					v4[1] = i;
				}
			}
		}
	}
	int pathcounter=0;
	if (vcounter >= 2 * n + 6) {
		cout << "Yes\n";
	}
	else if (vcounter == 2 * n + 4) {
		if (vcounter4 == 2) {
			for (i = 0; i < 4; i++) {
				if (pathcheck(v4[0], v4[1], e[v4[0]][i], v4[0]) == v4[1]) {
					pathcounter++;
				}
			}
			//cout << pathcounter;
			if (pathcounter == 2) {
				cout << "Yes\n";
			}
			else {
				cout << "No\n";
			}
		}
		else {
			cout << "Yes\n";
		}
	}
	else {
		cout << "No\n";
	}return 0;
}
int pathcheck(int a, int b, int vv, int from) {
	int i;
	int j;
	for (i = 0; i < 4; i++) {
		if (e[vv][i] == from) {

		}
		else if (e[vv][i] == a) {
			return a;
		}
		else if (e[vv][i] == b) {
			return b;
		}
		else {
			return pathcheck(a, b, e[vv][i], vv);
		}
	}
}

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

//s = (p1, p2, p3, ..., pn, 1, 2, 3, ..., n)
//p is a permutation of (1, 2, 3, ..., n)
//the number of good subsequences of s is the non-empty increasing
//subsequences of (p1, p2, p3, ..., pn)
//f(p) = number of (possibly empty) increasing subsequences of (p1, ..., pn)
//we find a p, such that f(p) = n + 1.
//f(empty-sequence) = 1
//f(q1, ..., qk, k + 1) = 2 * f(q1, ..., qk)
//q(k + 1, q1, ..., qk) = f(q1, ..., qk) + 1

#define ll long long

ll n;
std::deque<int> deque;

void getf(ll x){
	static int k = 0;
	if(x == 1) return;
	if(x & 1){
		getf(x - 1);
		deque.push_front(++ k);
	}
	else{
		getf(x / 2);
		deque.push_back(++ k);
	}
}

int main(){
	scanf("%lld", &n);
	getf(n + 1);
	int ans = deque.size();
	printf("%d\n", ans * 2);
	for(auto v : deque){
		printf("%d ", v);
	}
	for(int i = 1; i <= ans; ++ i){
		printf("%d%c", i, " \n"[i == ans]);
	}
	return 0;
}

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

using namespace std;

int M, W;
int Bm[12], Bw[12];
int DpElectrical[1 << 12];


int calculation(int i, int j) {
	int num;

	num = abs(Bm[i] - Bw[j]);
	return num * pow(num - 30, 2);
}

void solve() {

	fill(DpElectrical, DpElectrical + (1 << W), -1);
	DpElectrical[0] = 0;

	for (int i = 0; i < M; ++i) {
		for (int j = (1 << W) - 1; j >= 0; --j) {
			if (DpElectrical[j] == -1) {
				continue;
			}
			for (int k = 0; k < W; ++k) {
				if (((j >> k) & 1) == 1) {
					continue;
				}
				DpElectrical[j|(1 << k)] = max(DpElectrical[j|(1 << k)], DpElectrical[j] + calculation(i, k));
			}
		}
	}
}

int main() {

	while (cin >> M >> W, M) {
		memset(Bm, 0, sizeof(Bm));
		memset(Bw, 0, sizeof(Bw));
		for (int i = 0; i < M; ++i) {
			cin >> Bm[i];
		}
		for (int i = 0; i < W; ++i) {
			cin >> Bw[i];
		}
		solve();
		cout<<*max_element(DpElectrical, DpElectrical + (1 << W))<< endl;
	}

	return 0;
}



Measured memory_bytes: 3096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const ll INF = INT64_MAX/10;

struct edge{
    int to;
    ll cost1, cost2;
    edge(int x=0, ll y=0LL, ll z=0LL):to(x), cost1(y), cost2(z) {}
};

vector<vector<edge> > G;

struct Edge {
    int to;
    int64_t cost;
    Edge(int x=0, int64_t y=0):to(x), cost(y) {}
};

struct dijkstra {
    vector<int64_t> d;
    vector<vector<Edge> > G;
    dijkstra(int s, int n, vector<vector<Edge> >& g):d(n, INT64_MAX/3), G(g) { // sはスタート,nは頂点数
        d[s] = 0LL;
        priority_queue<pair<int64_t, int>, vector<pair<int64_t, int> >, greater<pair<int64_t, int> > > que;
        que.push(make_pair(0LL, s));
        while(!que.empty()) {
            pair<int64_t, int> now = que.top();
            que.pop();
            if(now.first != d[now.second]) continue;
            for(Edge next:G[now.second]) {
                if(d[next.to] > d[now.second] + next.cost) {
                    d[next.to] = d[now.second] + next.cost;
                    que.push(make_pair(d[next.to], next.to));
                }
            }
        }
    }
};

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s;
    --t;
    vector<vector<Edge> > G_1(n), G_2(n);
    rep(i, m) {
        int a, b;
        ll c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        G_1[a].push_back(Edge(b, c));
        G_1[b].push_back(Edge(a, c));
        G_2[a].push_back(Edge(b, d));
        G_2[b].push_back(Edge(a, d));
    }

    
    dijkstra d1(s, n, G_1);
    dijkstra d2(t, n, G_2);
    
    
    ll mm = 1e15;

    vector<ll> ans(n);


    rep(i, n) {
        ans[i] = d1.d[i] + d2.d[i];
    }
    rep(i, n-1) {
        if(ans[n-1-i] < ans[n-2-i]) {
            ans[n-2-i] = ans[n-1-i];
        }
    }

    rep(i, n) {
        cout << mm-ans[i] << endl;
    }
}


Measured memory_bytes: 32896
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

	int h = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
	int k = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;

	puts(h > k ? "hiroshi" : h < k ? "kenjiro" : "even");
}


Measured memory_bytes: 3068
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int a,b;
    string s;
    
    cin>>a>>b>>s;
    int h=0;
    
    if(s[a]!='-'){
        h=1;
    }else{
        for(int i=0;i<a;i++){
            if(s[i]=='-'){
                h=1;
            }
        }
        
        for(int i=a+1;i<a+b+1;i++){
            if(s[i]=='-'){
                h=1;
            }
        }
    }
    
    
    if(h==1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
    return 0;
}









Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut xy = vec![];
    for _ in 0..n {
        let x: f64 = sc.read();
        let y: f64 = sc.read();
        xy.push((x, y));
    }

    xy.sort_by(|&(ax, ay), &(bx, by)| {
        let a = ay.atan2(ax);
        let b = by.atan2(bx);
        a.partial_cmp(&b).unwrap()
    });

    let mut ans = 0.0;
    for i in 0..n {
        for count in 1..(n + 1) {
            let (mut x, mut y) = (0.0, 0.0);
            for i in i..(i + count) {
                let (dx, dy) = xy[i % n];
                x += dx;
                y += dy;
            }
            let d = x * x + y * y;
            if ans < d {
                ans = d;
            }
        }
    }
    println!("{}", ans.sqrt());
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<double> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  double under = 0;
  for (int i = 0; i < N; i++) {
    under += (1.0 / A[i]);
  }

  cout << 1.0 / under << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
#define mod 998244353
using namespace std;
ll dp[200000 + 1];
unsigned ll pre[200000 + 1];
int main()
{
// #ifndef HP
//   freopen("in.txt", "r", stdin);
//   freopen("out.txt", "w", stdout);
// #endif
 
  fastio;
  int t = 1;
  //cin >> t;
  while (t--)
  {
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll> > v;
    f(i, 0, k - 1)
    {
      ll p, q;
      cin >> p >> q;
      v.pb({p, q});
    }
    dp[0] = 0;
    dp[1] = 1;
    pre[0] = 0;
    pre[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
      for (ll j = 0; j < v.size(); j++)
      {
        {
          ll x = max(0LL, i - v[j].F);
          ll y = max(0LL, i - v[j].S - 1);
          dp[i] = (dp[i] + pre[x] - pre[y] ) % mod;
        }
      }
      pre[i] = (pre[i - 1] + dp[i]);
    }
    cout << dp[n] << endl;
  }
}


Measured memory_bytes: 6748
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define lld long long

int main(){
    int num[3][3];
    bool open[3][3];
    memset(open,false,3*3);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> num[i][j];
        }
    }
    int n,ball;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> ball;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(num[i][j] == ball){
                    open[i][j] = true;
                }
            }
        }
    }
    if( (open[0][0] && open[0][1] && open[0][2]) ||
        (open[1][0] && open[1][1] && open[1][2]) ||
        (open[2][0] && open[2][1] && open[2][2]) ||
        (open[0][0] && open[1][0] && open[2][0]) ||
        (open[0][1] && open[1][1] && open[2][1]) ||
        (open[0][2] && open[1][2] && open[2][2]) ||
        (open[0][0] && open[1][1] && open[2][2]) ||
        (open[0][2] && open[1][1] && open[2][0]) ){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
}

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

int main() {
    int n;
    cin >> n;
    vector<P> RED;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        RED.push_back({-b, a});
    }
    sort(RED.begin(), RED.end());
    rep(i, n) {
        RED[i].first *= -1;
    }
    vector<P> BULE;
    rep(i, n) {
        int c, d;
        cin >> c >> d;
        BULE.push_back({c, d});
    }
    sort(BULE.begin(), BULE.end());
    vector<bool> check(n, false);

    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (check[j]) continue;
            if (BULE[i].first > RED[j].second && BULE[i].second > RED[j].first) {
                check[j] = true;
                ans++; 
                break;
            }
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

string S, T, U;
int A, B;

int main() {
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S) {
        A = A - 1;
    } else {
        B = B - 1;
    }

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5;
ll dp[N][N];
struct p{
	int x,id;
	bool operator<(const p&a)const{
		return x>a.x; 
	}
}a[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i].x),a[i].id=i;
	sort(a+1,a+n+1);//从大到小排序 
	for(int k=1;k<=n;k++)//对第k个元素进行放置(前k-1个元素所有情况都已知) 
		for(int i=0;i<k;i++)//遍历前k-1元素的所有情况. i为往左放置的个数. 
		{
			int j=k-1-i;//前k-1元素往右放置的个数. 
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]+(ll)a[k].x*(a[k].id-(i+1)));//往左放 
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]+(ll)a[k].x*(n-j-a[k].id));//往右放 
		}
	ll ans=0;
	for(int i=0;i<=n;i++) ans=max(ans,dp[i][n-i]);//取最大值. 
	printf("%lld\n",ans);
	return 0;
}
 

Measured memory_bytes: 26420
N = int(input())

E = [None] * N
for _ in range(N):
    u, k, *vs = map(int, input().split())
    E[u] = []
    for i in range(k):
        v, c = vs[i*2], vs[i*2+1]
        E[u].append((v, c))

vis = [False] * N
inf = 1e9
d = [inf] * N
d[0] = 0
for _ in range(N):
    nv, ni = inf, -1
    for i in range(N):
        if not vis[i] and d[i] < nv:
            nv, ni = d[i], i
    vis[ni] = True
    for v, c in E[ni]:
        d[v] = min(d[v], d[ni] + c)

for v in range(N):
    print(v, d[v])


Measured memory_bytes: 6140
#include <stdio.h>

int nextInt() { int d; scanf("%d", &d); return d; }

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

int main() {
  int x = nextInt();
  int y = nextInt();

  printf("%d\n", gcd(x, y));
  return 0;
}

Measured memory_bytes: 1020
import java.util.*;

public class Main {
    	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int[] a = new int[2*n];
		for(int i=0; i<2*n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int cnt=0;
		for(int i=0; i<2*n; i+=2) cnt+=a[i];
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+20;
const int M=22;
int a[N][N];
string s;
int b[N],h[N];


int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		for(int i=0;i<n;i++)
		{
			cin>>s;
			for(int j=0;s[j];j++)
				a[i][j]=s[j]=='#'?1:0;
		}
		int ans=max(n,m);
		for (int i = 0; i < n; ++i)
	    {
	    	for (int j = 0; j < m; ++j)
	    	{	
				if(i&&!(a[i-1][j+1]^a[i][j]^a[i-1][j]^a[i][j+1])) h[j]++;
            		else h[j]=1;
			}
			int t=0;
			for(int j=0;j<=m-1;j++)
			{
				while(t&&h[b[t-1]]>=h[j])
				{
					int x=b[--t];
					if(t==0) ans=max(ans,(j+1)*h[x]);
					else ans=max(ans,(j-b[t-1])*h[x]);
				}
				b[t++]=j;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 16000
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


def solve(n: int, v: "List[int]"):
    c0 = Counter(v[0::2])
    c1 = Counter(v[1::2])

    # print(c0)
    # print(c1)
    c0[0] = 0
    c1[0] = 0

    mc0 = c0.most_common(2)
    mc1 = c1.most_common(2)

    v0, v1 = -INF, -INF

    if mc0[0][0] == mc1[0][0]:
        if mc0[0][1] + mc1[1][1] < mc0[1][1] + mc1[0][1]:
            v0 = mc0[1][1]
            v1 = mc1[0][1]
        else:
            v0 = mc0[0][1]
            v1 = mc1[1][1]
    else:
        v0 = mc0[0][1]
        v1 = mc1[0][1]

    print(n - v0-v1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23836
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string s; cin >> s;
	REP(i, s.size()){
		if(s[i] == '9') cout << '1';
		else if(s[i] == '1') cout << '9';
		else cout << s[i]; 
	}cout << endl;
}


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

#define all(c) (c).begin(), (c).end()

int main(){
    int n;
    cin>>n;
    while(n--){
        set<string> S;
        string s; cin>>s;
        S.insert(s);
        for(int i=1; i<s.size(); i++){
            string t = s.substr(0,i);
            string u = s.substr(i);
            S.insert(u+t);
            S.insert(t+u);
            reverse(all(t));
            S.insert(t+u);
            S.insert(u+t);
            reverse(all(u));
            S.insert(t+u);
            S.insert(u+t);
            reverse(all(t));
            S.insert(t+u);
            S.insert(u+t);
        }
        reverse(all(s));
        S.insert(s);

        cout << S.size() << endl;
    }
}

Measured memory_bytes: 1296
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main()
{
    int N=0;
    int bingo[9];
    set<int> number;
    int x;
    int key;
    bool call[9];
    

    for(int i=0;i<9;i++){
        cin >> bingo[i];
        call[i] = false;
    }
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> x;
        number.insert(x);
    }

    for(int i=0;i<9;i++){
        key = bingo[i];
        if(number.find(key)!=number.end())call[i]=true;
    }
    for(int i=0;i<3;i++){
        if(call[3*i] && call[3*i+1] && call[3*i+2]){
            cout <<"Yes" << endl;
            return 0;
        }
    }
    for(int i=0;i<3;i++){
        if(call[i] && call[i+3] && call[i+6]){
            cout <<"Yes" << endl;
            return 0;
        }
    }
    if(call[0] && call[4] && call[8]){
        cout <<"Yes" << endl;
        return 0;
    }
    if(call[2] && call[4] && call[6]){
        cout <<"Yes" << endl;
        return 0;
    }

    cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    val a = Math.min(n, m / 2)
    val remM = m - a * 2
    val b = remM / 4
    println(a + b)
}

Measured memory_bytes: 31268
#include <iostream>
#include <map>

long long pow(long long a, long long x)
{
  long long result = 1;
  for (long long i = 0; i < x; i++) {
    result = result * a;
  }
  return result;
}

int main()
{
  long long n, p;
  std::cin >> n >> p;
  std::map<long long, long long> cnt;
  long long rest = p;
  for (long long i = 2; i * i <= p; i++) {
    while (rest % i == 0) {
      rest = rest / i;
      cnt[i]++;
    }
  }
  cnt[rest]++;
  long long result = 1;
  for (const auto& x : cnt) {
    result = result * pow(x.first, x.second / n);
  }
  std::cout << result << std::endl;
  return 0;
}


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

int main(){
    int N,L,T;
    cin >> N >> L >> T;
    vector<int> X(N);
    vector<int> W(N);
    vector<int> A(N);
    vector<int> R(N);
    rep(i,N){
        cin >> X[i] >> W[i];
        if(W[i] == 1){
            A[i] = X[i] + T;
            A[i] %= L; 
        }else{
            A[i] = X[i] - T;
            A[i] %= L;
            if(A[i] < 0) A[i] += L;
        }
    }
    int cnt = 0;
    rep(i,N){
        if(W[i] == 1){
            cnt -= (X[i]+T)/L;
        }else{
            cnt += (T - (X[i] + 1) + L) / L;
            //cnt += (T / L);
            //if((T%L) < X[i]) cnt -= 1; 
        }
    }
    sort(A.begin(), A.end());

    cnt = (cnt % N + N) % N;
    for (int i = 0; i < N; ++i) R[(i+cnt)%N] = A[i];
    for (int i = 0; i < N; ++i) cout << R[i] << endl;
    /*
    int cnt = 0;
    int itr = 0;
    int rec = A[0];4 20 9
7 2
9 1
12 1
18 1
    for(int i=1;i<N;i++){
        if(W[0] == 1){
            if(W[0] != W[i]){
                if(X[i] - X[0] < 2*T) cnt++;
            } 
        }else{
            if(W[0] != W[i]){
                if(L-(X[i] - X[0]) <2*T) cnt++;
            }
        }
    }
    sort(A.begin(), A.end());
    if(W[0] == 1){
    rep(i,N){
        if(rec == A[i]){
            if(W[0] == 1){
                if(i - cnt < 0){
                    itr = i-cnt+N;
                }else{
                    itr = i-cnt;
                } 
            }else{
                if(i-(N-cnt) < 0){
                    itr = i-(N-cnt)+N;
                }else{
                    itr = i-(N-cnt);
                }
            }

            break;
        }
    }
    }else{
        for(int i=N-1;i>=0;i--){
        if(rec == A[i]){
            if(W[0] == 1){
                if(i - cnt < 0){
                    itr = i-cnt+N;
                }else{
                    itr = i-cnt;
                } 
            }else{
                if(i-(N-cnt) < 0){
                    itr = i-(N-cnt)+N;
                }else{
                    itr = i-(N-cnt);
                }
            }
            break;
        }
    }
    }
    for(int i=0;i<N;i++){
        if(i+itr < N){
            cout << A[i+itr] << endl;
        }else{
            cout << A[i+itr-N] << endl;
        }
    }
    */
    //cout << "aaa:"<< rec <<","<<N-cnt<< endl;

}



Measured memory_bytes: 2816
<?php
fscanf(STDIN, "%d%d%d%d", $a, $b, $h, $m);


$minx = $b * sin($m/60 * 2 * pi());
$miny = $b * cos($m/60 * 2 * pi());
$hourx = $a * sin(($h + $m/60) / 12 * 2 * pi());
$houry = $a * cos(($h + $m/60) / 12 *2 * pi());

echo sqrt(pow($houry - $miny, 2) + pow($hourx - $minx, 2));

Measured memory_bytes: 16684
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
ll a[2000];
ll b[2000][2000];
int main( void )
{
  ios::sync_with_stdio(false);
  ll N, x;
  cin >> N >> x;
  for( int i=0; i<N; i++ ) cin >> a[i];
  for( int i=0; i<N; i++ ){
    b[i][0] = a[i];
    for( int j=1; j<N; j++ ){
      b[i][j] = min( b[i][j-1], a[(i+N-j)%N] );
    }
  }
  ll ret;
  for( int i=0; i<N; i++ ){
    ll c = 0;
    for( int j=0; j<N; j++ ){
      c += b[j][i];
    }
    if( i == 0 ) ret = c;
    else ret = min( ret, c + i * x );
  }
  cout << ret << endl;
}

Measured memory_bytes: 31488
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		var t=sc.S;
		var h=new int[30];
		h=Enumerable.Repeat(t.Length,'z'-'0'+1).ToArray();
		StringBuilder sb=new StringBuilder();
		int o='0';
		for(int i = 0;i<t.Length-1;i++) {h[t[i]-o]=t.Length-i-1;}
		for(int i = 0;i<s.Length+1-t.Length;i++) {
			for(int j = 1;j<=t.Length;j++) {
				if(s[i+t.Length-j]!=t[t.Length-j]){
					i+=Max(h[s[i+t.Length-j]-o],j)-j;
					break;
				}
				else if(j==t.Length){sb.Append(i+"\n");}
			}
		}
		Console.Write(sb);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 20312
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

ll int ison[15];

ll int n,m;

ll int cnt=0;

ll int k[15];

ll int s[15][15];

ll int p[15];

void fun(ll int idx)
{
	if(idx==n+1)
	{
		for(ll int i=1;i<=m;i++)
		{
			ll int tmp=0;
			for(ll int j=1;j<=k[i];j++)
			{
				tmp+=ison[s[i][j]];
			}
			if(tmp%2==p[i]%2) continue;
			else return ;
		}
		cnt++;
	}
	else
	{
		ison[idx]=0;
		fun(idx+1);
		ison[idx]=1;
		fun(idx+1);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		cin>>n>>m;
		for(ll int i=1;i<=m;i++)
		{
			cin>>k[i];
			for(ll int j=1;j<=k[i];j++)
			{
				cin>>s[i][j];
			}
		}
		for(ll int i=1;i<=m;i++) cin>>p[i];
		fun(1);
		cout<<cnt;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    string s[8]={"","SAT","FRI","THU","WED","TUE","MON","SUN"};
    string in;
    cin>>in;
    REP(i,8)if(in==s[i])cout<<i<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
int find_ab(std::vector<long long> &vx);
int main(void){
    std::vector<long long> v;
    long long N,tmp,alen=-1,blen=-1;
    std::cin>>N;
    while(std::cin>>tmp){
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end(), std::greater<long long>());
    if(N>=4){
        alen=find_ab(v);
        blen=find_ab(v);
    }
    if(alen==-1 || blen==-1){
        std::cout<<0<<std::endl;
    }else{
        std::cout<<alen*blen<<std::endl;
    }
    return 0;
}


int find_ab(std::vector<long long> &vx){
    long long xlen=-1,tmp=-1;
    for(auto i=vx.begin();i!=vx.end();i++){
        if(tmp==*i){
            xlen=tmp;
            vx.erase(i);
            vx.erase(i-1);
            break;
        }else{
            tmp=*i;
        }
    }
    return xlen;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r=0,g=0,b=0;
    rep(i,n){
      if(s[i]=='R') r++;
      if(s[i]=='G') g++;
      if(s[i]=='B') b++;
    }
    ll ans=0;
    ans=r*g*b;
    rep(j,n){
      rep(i,j){
        ll k=2*j-i;
        if(k<n){
          if(s[i]==s[j]) continue;
          if(s[j]==s[k]) continue;
          if(s[i]==s[k]) continue;
          ans--;
        }
      }
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>

int main()
{
    int K, N;
    std::cin >> K >> N;

    int A[N];
    int i;

    for (i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int max = 0;
    for (i = 0; i < N - 1; i ++) {
        if (max < A[i + 1] - A[i]) max = A[i + 1] - A[i];
    }
    if (max < K - A[N - 1] + A[0]) max = K - A[N - 1] + A[0];

    std::cout << K - max;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;



int main(void){
    string s;
    cin>>s;
    ll a,b,c,d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    for(ll i:{1,-1}) for(ll j:{1,-1}) for(ll k:{1,-1}){
        if(a+i*b+j*c+k*d == 7){
            cout<<a;
            if(i>0) cout<<"+";
            else cout<<"-";
            cout<<b;
            if(j>0) cout<<"+";
            else cout<<"-";
            cout<<c;
            if(k>0) cout<<"+";
            else cout<<"-";
            cout<<d<<"=7"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int  main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=13)  printf("%d\n",b);
    else if(a>=6 and a<=12) printf("%d\n",b/2);
    else printf("0\n");
}



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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define FOUND(u, val) u.find(val) != u.end()
#define max_self(a, b) a = max(a, b);

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n;
    cin >> n;

    int base = 1;
    while (base <= n) base *= 2;
    vl tree(2 * base);

    ll heights[n], ar[n];
    for (ll &x : heights) cin >> x;
    for (ll &x : ar) cin >> x;

    /* 
9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 3 5 7 5
 */
    /* 
4
3 1 4 2
10 20 30 40
 */

    vl dp(n + 1, 0);
    ll ans = 0;
    for (int flower = 0; flower < n; flower++) {
        int x = heights[flower] + base;
        ll best = 0;
        while (x > 1) {
            if (x % 2 == 1) {
                max_self(best, tree[x - 1]);
            }
            x /= 2;
        }

        dp[heights[flower]] = best + ar[flower];

        for (int i = base + heights[flower]; i >= 1; i /= 2) {
            max_self(tree[i], dp[heights[flower]]);
        }
    }

    // Below is O(n ^2) solution
    /* vl dp(n + 1, 0);
    // dp[i] - the max total beauty so far if the last taken flower has height i.
    ll ans = 0;
    // GO through every flower
    for (int flower = 0; flower < n; flower++) {
        // Go through all flowers shorter in length
        for (int i = 0; i < heights[flower]; ++i) {
            // If the sum for a shorter flower (dp[i]) + current flower value
            //  is greater than sum for current flower, update it.
            if (dp[i] + ar[flower] > dp[heights[flower]])
                dp[heights[flower]] = dp[i] + ar[flower];
        }
    } */
    for (int i = 0; i <= n; i++) max_self(ans, dp[i]);
    cout << ans;
}

Measured memory_bytes: 11932
import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    p = list(map(float, input().split()))

    # dp[j] := 表が j 枚となる確率
    # dp[j] = dp[j-1]*p[i] + dp[j]*(1-p[i]) ただしdp[j]が重複していることに注意
    dp = [0.0] * (N+1)
    # 初期条件
    dp[0]= 1.0

    for i in range(N):
        p_head = p[i]
        p_tail = 1 - p[i]
        dp = [dp[j -1] * p_head + dp[j] * p_tail for j in range(N+1)]
    
    ans = sum(dp[(N//2+1):])

    print(ans)

main()

Measured memory_bytes: 3444
a=int(input())
i=1
end=0
while(i<=9 and end ==0):
    j=1
    while(j<=9 and end==0):
        if i*j==a:
            print('Yes')
            end=1
        j+=1
    i+=1
    if end ==1:
        break
if end ==0:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int n;
  int j=0;
  while (cin >> n && n) {
    j++;
    double x[n], y[n];
    for (int i=0; i<n; i++)
      cin >> x[i] >> y[i];
    double ans = 0;
    for (int i=1; i<n-1; i++) {
      double dx1 = x[i]-x[0];
      double dy1 = y[i]-y[0];
      double dx2 = x[i+1]-x[0];
      double dy2 = y[i+1]-y[0];

      ans += dy1*dx2 - dx1*dy2;
    }
    printf("%d %.1f\n", j, ans/2);
  }
}

Measured memory_bytes: 0