akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    int sz = (int)s.size();
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        int SZ = (int)t.size();
        for (int j = 0; j <= SZ - sz; j++) {
            bool ok = false;
            for(int kankaku = 1; j + kankaku * (sz - 1) < SZ; kankaku++) {
                bool flg = true;
				string tmp;
                for (int k = 0; k < sz; k++) {
                    if (j + kankaku * k >= SZ) {
                        flg = false;
                        break;
                    }
                    if (s[k] != t[j + kankaku * k]) {
                        flg = false;
                        break;
                    }
                }
                if (flg) {
                    ok = true;
                    break;
                }
            }
            if (ok) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		double k = sc.nextDouble();
		sc.close();
		
		double p = 0;
		
		for(int i=1; i<=n; i++) {
			if(i<k) {
				p += 1/n * Math.pow(0.5, (int)(Math.log10((k-1)/i)/Math.log10(2)+1));
			}else {
				p += 1/n;
			}
		}
		System.out.println(p);
	}

}


Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()

#define rep(i, n) for (int i = 0; i < (int)n; i++)

int main(){
    string S, T; cin >> S >> T;
    bool flag = false;
    for (int i = 0; i < 26; i++)
    {
        string v = S + (char)((int)'a' + i);
        if (v == T) flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}
    

Measured memory_bytes: 3548
n,m,l = map(int,input().split())

nm = []
for i in range(n):
    nm_value = list(map(int,input().split()))
    nm.append(nm_value)

ml=[]
for j in range(m):
    ml_value = list(map(int,input().split()))
    ml.append(ml_value)

C = [[0 for row in range(l)] for column in range(n)] 
for i in range(n):
    for j in range(m):
        for k in range(l):
            C[i][k] += nm[i][j]*ml[j][k]

for i in range(n):
    print (*C[i])


Measured memory_bytes: 7064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main()
{
    int A, B, C, X;
    int ans = 0;

    cin >> A >> B >> C >> X;

    for( int a = 0; a <= A; a++ )
    {
        for( int b = 0; b <= B; b++ )
        {
            for( int c = 0; c <= C; c++ )
            {
                if( (500 * a + 100 * b + 50 * c) == X )
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n, m, q = gets.split.map(&:to_i)
dp = Array.new(n+1) { Array.new(n+1, 0)}
m.times do
  l, r = gets.split.map(&:to_i)
  dp[l][r] += 1
end

n.times do |i|
  n.times do |j|
    dp[i+1][j+1] += dp[i+1][j] + dp[i][j+1] - dp[i][j] 
  end
end

q.times do
  p0, q0 = gets.split.map(&:to_i)
  p dp[q0][q0] - dp[q0][p0-1] - dp[p0-1][q0] + dp[p0-1][p0-1]
end


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

int main(){
	char c[3][3];
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256
def D():
    nxy=list(map(int,input().split()))
    count_list=[0]*nxy[0]
    
    for i in range(1,nxy[0]):
        for j in range(i+1,nxy[0]+1):
            mins=min(abs(j-i),abs(nxy[1]-i)+1+abs(j-nxy[2]))
            count_list[mins]+=1
            
    for i in range(1,nxy[0]):
        print(count_list[i])
            
        
if __name__=='__main__':
    D()

Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict

N, M, X = map(int, input().split())
B = []
for i in range(N):
    B.append(list(map(int, input().split())))
ans = 10**18
for i in range(1<<N):
    c = 0
    r = [0]*M
    for j in range(N):
        if (i>>j)&1:
            c += B[j][0]
            for k in range(1, M+1):
                r[k-1] += B[j][k]
    if all([x >= X for x in r]):
        ans = min(ans, c)
if ans == 10**18:
    ans = -1
print(ans)

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int n, q;
vector<int> A;

bool solve(int i, int m) {
    if ( m == 0 ) return true;
    if ( i >= n ) return false;
    // 左はi番目の要素を選ばない場合
    // 右はi番目の要素を選んだ場合
    return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

// bool solve(int m) {
//     for (int bit = 0; bit < (1 << n); ++bit) {

//         int sum = 0;
//         for (int i = 0; i < n; ++i) {
//             if (bit & (1 << i)) {
//                 sum += A[i];
//                 if (sum > m) break;
//             }
//         }

//         if (sum == m) return true;
//     }
//     return false;
// }

int main(void) {

    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    cin >> q;
    rep(i, q) {
        int m;
        cin >> m;
        if (solve(0, m)) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    return 0;
}


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

const int N = 2e5 + 9, P = 1e9 + 7;

int h, w, a, b, fac[N], inv[N], ans;

int C (int a, int b) { return 1ll * fac[a] * inv[b] % P * inv[a - b] % P; }

int main () {
	scanf("%d%d%d%d", &h, &w, &a, &b);
	int n = max(h - a + w - 2, w - b - 1 + a);
	fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	inv[0] = inv[1] = 1; for (int i = 2; i <= n; ++i) inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
	for (int i = 2; i <= n; ++i) inv[i] = 1ll * inv[i] * inv[i - 1] % P;
	for (int i = b + 1; i <= w; ++i)
	ans = (1ll * C(h - a + i - 2, i - 1) * C(w - i + a - 1, w - i) + ans) % P;
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt() - 1;
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += b[a[i]];
			if(i > 0 && a[i] == a[i - 1] + 1) {
				ans += c[a[i - 1]];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
map<int,int>xc,yc;
struct node{
	int x,y;
}p[N];
int numx,numy,cnt1,cnt2,cnt,h,w,m;
int main(){
	scanf("%d%d%d",&h,&w,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		p[i]={x,y};
		xc[x]++;yc[y]++;
		numx=max(numx,xc[x]),numy=max(numy,yc[y]);
	}
	for(auto it=xc.begin();it!=xc.end();it++){
		int d=it->second;
		if(d==numx)cnt1++;
	}
	for(auto it=yc.begin();it!=yc.end();it++){
		int d=it->second;
		if(d==numy)cnt2++; 
	}
//	printf("%d %d\n",numx,numy);
	for(int i=1;i<=m;i++){
		if(xc[p[i].x]==numx&&yc[p[i].y]==numy)cnt++;
	}
//	printf("%d %d %d\n",cnt,cnt1,cnt2);
	if(cnt==cnt1*cnt2){
		printf("%d\n",numx+numy-1);
	}
	else printf("%d\n",numx+numy);
	return 0;
}


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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
	int n, x, t;
	read(n, x, t);
	println((n + x - 1) / x * t);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A, B;
  cin >> A >> B;
  
  if(A > B) cout << A * 2 - 1 << endl;
  else if(A == B) cout << A * 2 << endl;
  else cout << B * 2 - 1 << endl;
 
return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 3564
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		int[] w = new int[n];
		int[] e = new int[n];
		for (i = 1; i < n; i++) {
			w[i] = w[i-1] + (s[i-1]=='W'?1:0);
			e[n-1-i] = e[n-i] + (s[n-i]=='E'?1:0);
		}
//		out.println(Arrays.toString(w));
//		out.println(Arrays.toString(e));
		int mn = n;
		int tmp = 0;
		for (i = 0; i < n; i++) {
			tmp = w[i] + e[i];
			if(tmp < mn) mn = tmp;
		}
		out.println(mn);
	}
}

Measured memory_bytes: 32060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double H , N;
  cin >> H >> N;
  double x;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  
   for (int i = 0; i < N; i++) {
    x += vec.at(i);
  }
  
  if (x >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=300000;

int n;
int a[MAXN];

int sumodd,sumevn;

bool can(int want) {
	if(want<sumodd) return true;
	int need=want-sumodd;
	int cur=0;
	for(int i=0;i<n;i+=2) {
		if(i>0) { if(cur>=need&&cur-a[i-1]<0) cur=0; else cur-=a[i-1]; }
		cur+=a[i];
	}
	return cur>=need;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);

	sumodd=0,sumevn=0; REP(i,n) if(i%2==0) sumevn+=a[i]; else sumodd+=a[i];
	if(n%2==0) {
		printf("%d %d\n",max(sumodd,sumevn),min(sumodd,sumevn));
	} else {
		int l=max(sumodd,sumevn),h=sumodd+sumevn+1;
		while(l+1<h) {
			int m=l+(h-l)/2;
			if(can(m)) l=m; else h=m;
		}
		printf("%d %d\n",l,sumodd+sumevn-l);
	}
}

int main() {
	run();
	return 0;
}


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

constexpr const int maxn = 1024;
vector<int> adj[maxn], dag[maxn];
int die[maxn], deg[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, m;
	cin >> n >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		++deg[b];
	}
	vector<int> topo;
	for (int u = 1; u <= n; ++u) if (!deg[u]) topo.push_back(u);
	for (int i = 0; i != int(topo.size()); ++i) for (int u : adj[topo[i]]) if (!--deg[u]) topo.push_back(u);
	if (int(topo.size()) == n) return cout << -1 << endl, 0;
	for (int i = 1; i <= n; ++i) {
		die[i] = 1;
		vector<int> node;
		memset(deg, 0, maxn << 2);
		for (int u = 1; u <= n; ++u) dag[u].resize(0);
		for (int u = 1; u <= n; ++u) if (!die[u]) {
			node.push_back(u);
			for (int v : adj[u]) if (!die[v]) dag[u].push_back(v);
			for (int v : dag[u]) ++deg[v];
		}
		topo.resize(0);
		for (int u : node) if (!deg[u]) topo.push_back(u);
		for (int j = 0; j != int(topo.size()); ++j) for (int u : dag[topo[j]]) if (!--deg[u]) topo.push_back(u);
		if (topo.size() == node.size()) die[i] = 0;
	}
	vector<int> res;
	for (int i = 1; i <= n; ++i) if (!die[i]) res.push_back(i);
	cout << res.size() << endl;
	for (int ans : res) cout << ans << '\n';
}


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

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) (v.size())
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

LL MOD = 1000000007; 

using namespace std;


LL func(vector<LL> &v, LL X) {
    LL ans = 0;
    for(int i = 1; i < v.size(); ++i) {
        LL t = v[i - 1] + v[i];
        if (t > X) {
            LL diff = min(t - X, v[i]);
            ans += diff;
            v[i] -= diff;
        }
    }
    if (v[0] + v[1] > X) {
        LL diff = v[0] + v[1] - X;
        ans += diff;
        v[0] -= diff;
    }
    
    return ans;
}

int main(int argc, char *argv[]) {
    LL N, X, a;
    cin >> N >> X;
    vector<LL> v;
    FOR(i, 0, N) {
        cin >> a;
        v.push_back(a);
    }
    
    LL ans = func(v, X);
    reverse(ALL(v));
    ans += func(v, X);
    
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1400
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto dp = new long[][](10 ^^ 5 + 1, 3);
    long N = lread();
    auto ABC = new long[][](10 ^^ 5 + 1, 3);
    foreach (i; 0 .. N)
        scan(ABC[i][0], ABC[i][1], ABC[i][2]);

    foreach (i; 0 .. N)
    {
        foreach (j; 0 .. 3)
            dp[i + 1][j] = max(dp[i][(j + 1) % 3] + ABC[i][(j + 1) % 3],
                    dp[i][(j + 2) % 3] + ABC[i][(j + 2) % 3]);
    }
    writeln(dp[N][0].max(dp[N][1]).max(dp[N][2]));
}


Measured memory_bytes: 22952
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int valid(int n){
	if(ceil(sqrt(n)) == floor(sqrt(n))) return 1;
	return 0;
	}
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	int x = stoi(a+b);
	if(valid(x)) pf("Yes");
	else pf("No");
	
	return 0;
}

Measured memory_bytes: 3700
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=998244353,N=305,M=6e4+5;
int a[N],s,m,n,ans=1,f[M],g[M];

signed main(){
	read(n);
	for(int i=1;i<=n;i++) s+=read(a[i]),ans=3*ans%mod;m=s>>1;
	f[0]=1;for(int i=1;i<=n;i++) for(int j=m;j>=a[i];j--) f[j]=(f[j]+2*f[j-a[i]])%mod;
	for(int i=0;i<=m;i++) ans=(ans-3*f[i])%mod;
	if(~s&1){
		g[0]=1;for(int i=1;i<=n;i++) for(int j=m;j>=a[i];j--) g[j]=(g[j]+g[j-a[i]])%mod;
		ans=(ans+3*g[m])%mod;
	}
	write((ans+mod)%mod);
}

Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B,T;
  cin >> A >> B >> T;
  cout << (T / A) * B << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

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

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll n, m; cin >> n >> m;
  ll base = 100 * (n - m) + 1900 * m;
  ll flag = modpow(2, m);
  fin(base * flag);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int dp[105][4][2];

int main() {
	int N;
	cin >> N;
	int saidai = 1;
	map<string, int>m;
	for (int i = 0; i < N;++i) {
		string str;
		cin >> str;
		m[str]++;
		if (saidai < m[str])saidai = m[str];
	}
	for (auto ma : m) {
		if (ma.second == saidai){
			cout << ma.first << endl;
		}
	}
}



Measured memory_bytes: 27520
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int cnt = 0;

    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'o') {
        cnt++;
      }
    }

    System.out.println(700 + (cnt * 100));

  }
}

Measured memory_bytes: 35648
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <utility>
#include <iomanip>
#define input(a) cin >> a
#define print(x) cout << x << endl
#define rep(a,n) for(int i = a; i < n; i++)
#define ll long long int
using namespace std;


int main(){
    int a,b;
    string ans;
    cin >> a >> b;
    int c = a*b;
    if (c%2 == 0) ans = "Even";
    else ans = "Odd";
    print(ans);
    
    
    return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  l=[tuple(map(int,input().split())) for _ in range(n)]
  dp=[[0]*3 for _ in range(n+1)]
  for i in range(1,n+1):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+l[i-1][0]
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+l[i-1][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+l[i-1][2]
  print(max(dp[-1]))
if __name__=='__main__':
  main()

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

int main(void) {
	int N;
	cin >> N;
	string S;
	cin >> S;

	vector<int> s_int(N, -1);
	ll r_num = 0, g_num=0, b_num=0;
	for(int i=0; i<N; i++){
		if(S[i]=='R'){
			s_int[i] = 0;
			r_num++;
		}
		else if(S[i]=='G'){
			s_int[i] = 1;
			g_num++;
		}
		else if(S[i]=='B'){
			s_int[i] = 2;
			b_num++;
		}
	}

	ll rule1 = r_num * g_num * b_num;//条件１を満たす個数
	// ll rule1 = 1;
	// rule1 *= r_num;
	// rule1 *= g_num;
	// rule1 *= b_num;
	ll rule1_not2 = 0;//条件1を満たすが条件2を満たさない個数
	ll ans = 0; // ans = rule1 - rule1_not2;
	for(int i=0; i<N; i++){
		for(int j=i; j<N; j++){
			int k = 2*j - i;
			if(k < 0 || N <= k) continue;
			if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k]){
				//cout << " i:" << i << " j: " << j << " k: " << k << endl;
				rule1_not2++;
			}
		}
	}
	
	//cout << " rule1: " << rule1 << " rule1_not2: " << rule1_not2 << endl;
	ans = rule1 - rule1_not2;
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long LL;
const int M=505;
int a[M];
int n,k;

int rm[M];

bool check(int d)
{
	for(int i=0;i<n;i++)
		rm[i]=a[i]%d;
	sort(rm,rm+n);
	int sum=0;
	for(int i=0;i<n;i++)
		sum+=rm[i];
	int pre=0;
	for(int i=0;i<n;i++)
	{
		pre+=rm[i];
		if(pre==((LL)n-i-1)*d-(sum-pre)) break;
	}
	return pre<=k;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int sum=0;
	for(int i=0;i<n;i++)
		sum+=a[i];
	int ans=0;
	for(int i=1;i<=sum/i;i++)
	{
		if(sum%i) continue;
		if(check(sum/i))
		{
			ans=sum/i;
			break;
		}
		if(check(i))
			ans=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    if(A<B)
    {
        if(A+T*V >= B+T*W)
        cout<<"YES";
        else
        cout<<"NO";
    }
    else
    {
        if(A - T*V <= B - T*W)
        cout<<"YES";
        else
        cout<<"NO";
    }
    
    return 0;
}

Measured memory_bytes: 3636
public class Hello{
    public static void Main(){
        // Here your code !
        string input;
        input = System.Console.ReadLine();
        string[] abc = input.Split(' ');
        
        string result = Last(abc[0])==First(abc[1]) && Last(abc[1])==First(abc[2]) ? "YES": "NO";

        System.Console.WriteLine(result );
    }
    
    public static string First (string word)
    {
        return word.Substring(0,1);
    }
    
    public static string Last (string word)
    {
        return word.Substring(word.Length-1,1);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n,q;
	cin>>n;
	vector<int> S(n);
	for( int i=0; i<n; i++ ) {
		cin>>S.at(i);
	}
	cin>>q;
	int t;
	vector<int>::iterator iE = S.end( );
	int cnt = 0;
	for( int i=0; i<q; i++ ) {
		cin>>t;
		vector<int>::iterator iS = S.begin( );
		for( ; iS<iE; iS++ ) {
			if( t == *iS ) {
				cnt++;
				break;
			}
		}
	}
	cout<<cnt<<'\n';

    return 0;
}
	

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> data(N);
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    data.at(a - 1)++;
  }
  sort(data.begin(), data.end());
  int count = 0, anscount = 0, ans = 0;
  for(int i = 0; i < N; i++) {
    if (N - count - K == anscount) break;
    if (data.at(i) == 0) count++;
    else {
      ans += data.at(i);
      anscount++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
	return 0;
}

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

int main() 
{
  int a,b,k;
  cin >> a >> b >> k;
  int common_divisor[101];

  int n=min(a,b);
  int num[101]={0};

  for(int i=1; i<=n; i++)
  {
    if( a%i==0 && b%i==0 )
      num[i]=1;
  }

  int j=0;
  for(int i=1; i<=n; i++)
  {
    if(num[i]==1)
    {   
      common_divisor[j] = i;
      j++;
    }   
  }
    
  cout << common_divisor[j-k] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	int h, w, s=0;
	string a[8];
	cin >> h >> w;
	for(int i=0; i<h; i++){
		cin >> a[i];
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(a[i][j]=='#'){
				s++;
			}
		}
	}
	if(s==h+w-1){
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def dis2(x, y):
  T = []
  for i in range(len(x)):
    T.append((int(x[i])-int(y[i])) ** 2)
  return sum(T)

n, d = map(int, input().split())
x_list = [input().split() for _ in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1, n):
    R = dis2(x_list[i], x_list[j])
    for k in range(R+1):
      if k**2 == R:
        ans += 1
        continue

print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#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;
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    int w,h,n;
    cin>>w>>h>>n;
    int x[n],y[n],a[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>a[i];
    }
    int x1=0,y1=0,x2=w,y2=h;
    rep(i,n){
        if(a[i]==1){
            if(x1<x[i]) x1=x[i];
        }
        if(a[i]==2){
            if(x2>x[i]) x2=x[i];
        }
        if(a[i]==3){
            if(y1<y[i]) y1=y[i];
        }
        if(a[i]==4){
            if(y2>y[i]) y2=y[i];
        }
    }
    if(x1<x2 && y1<y2) cout<<(x2-x1)*(y2-y1)<<endl;
    else cout<<"0"<<endl;
    return 0;
}    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  vector<int> hs(N); for (auto &h : hs) cin >> h;
  vector<long long> dp(N + 200, 1LL << 40); dp[0] = 0;
  for (int i = 0; i < N - 1; ++i)
    {for (int j = 1; j <= K; ++j) dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]));}
  cout << dp[N - 1] << endl;}

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

int main() {
	int n;
	cin >> n;
	while (1) {
		if (n % 10 == ((n - n % 10) % 100) / 10 && n % 10 == (n - n % 100) / 100)break;
		n++;
	}
	cout << n << endl;
	return 0;
}

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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int B = 21;
int dp[1 << B];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	int a[n][n]; rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];
	dp[0] = 1;
	rep(S, 0, 1 << n) {
		int i = __builtin_popcount(S);
		rep(j, 0, n)
			if ((~S & 1 << j) && a[i][j])
				(dp[S | 1 << j] += dp[S]) %= M;
	}
	cout << dp[(1 << n) - 1];
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
using BL = bool;
using VBL = std::vector<BL>;
using VVBL = std::vector<VBL>;
using VVVBL = std::vector<VVBL>;


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; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define REPM(i,n,m) for(LL (i)=m;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
//#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

template<class T> 
void PRINTSP(vector<T> v, size_t w=3){
  for(auto (a): v ) {cerr <<setw(w)<< a << " ";} cerr << endl;
} 

template<typename TTT>
vector<LL> arg_sort(vector<TTT> A, bool ascend = true) {
  vector<LL> index(A.size());
  iota(index.begin(), index.end(), 0);
  if (ascend) {
    std::sort(index.begin(), index.end(), [&A](TTT i1, TTT i2) {
      return A[i1] < A[i2];
      });
  }
  else {
    std::sort(index.begin(), index.end(), [&A](TTT i1, TTT i2) {
      return A[i1] > A[i2];
      });
  }

  return index;
}

#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N, LL minus = 0){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
    A[i] -= minus;
  }
  return move(A);
}
inline VVLL zerosll(LL H, LL W, LL val=0){
  VVLL A(H,VLL(W,val));
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



VVVLL X;
VLL D;

void dfs(LL me,LL cost, LL oya){
  D[me]=cost;
  //cerr << "me "<< me<< " cost" << cost<<endl; 
  //PRINTSP(D);
  for(LL i=0; i< X[me].size();++i){
    LL to = X[me][i][0];
    LL c  = X[me][i][1];
    if(to==oya){
      continue;
    }

    dfs(to,c+cost,me);

  }


}

void func(){
  LL N;
  cin >> N;
  X.resize(N);
  D.resize(N);

  REP(i,N-1){
    LL a,b,c; 
    cin >> a;
    cin >> b;
    cin >> c;
    a--;
    b--;
    X[a].push_back({b,c});
    X[b].push_back({a,c});
  }
  LL Q,K;
  cin >> Q;
  cin >> K;
  K--;
  dfs(K,0,-1);
  //PRINTSP(D);

  REP(i,Q){
    LL x,y;
    cin >> x;
    cin >> y;
    x--;
    y--;

    cout << D[x]+D[y] << endl;
  }
}
int main()
{
  func();
  return 0;
}
 

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

using namespace std;

int main()
{
  string s;
  cin>>s;
  if(s[0]=='7')
    cout<<"Yes";
  else if(s[1]=='7')
  {
      cout<<"Yes";

  }
  else if(s[2]=='7')
  {
      cout<<"Yes";
  }
  else
    cout<<"No";
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	double x1 = scan.nextDouble();
	double y1 = scan.nextDouble();
	double x2 = scan.nextDouble();
	double y2 = scan.nextDouble();
	
	double x = (x1 - x2) * (x1 - x2);
	double y = (y1 - y2) * (y1 - y2);
	
	double z12 = x + y;
		
	double z = Math.sqrt(z12);
	
	System.out.printf("%.8f\n", z);
	}
}


Measured memory_bytes: 28180
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;
 
int inp(){
  int x; 
  cin>>x;
  return x;
}
 
//=============================================================================//
 
void solve() {
    ll k; 
    cin>>k;
    
    if(k%2==0) cout<<-1;
    else{
      ll num = 7;
      ll ans = 1;
      while(num%k != 0){
        num = (num*10+7) % k;
        ans++;
        if(ans>k){ cout<<-1; return;}
      }
      cout<<ans;
      }
}
 
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
 
    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }
    
    return 0;
}

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

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

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

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

int N;
ll A[200005];
ll B[200005];
ll C[200005];
ll D[35];

//! under以上になる最小のindex
int getUnder(ll under)
{
    if (under <= 0)
        return 0;
    int ok = N, ng = -1;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] >= under)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}
//! top未満になる最大のindex
int getTop(ll top)
{
    int ok = -1, ng = N;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] < top)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    ll ans = 0;
    ll bit = 1;
    REP(i, 29)
    {
        D[i] = 0;
        bit <<= 1;
        REP(j, N)
        {
            C[j] = (B[j] % bit);
        }
        sort(C, C + N);
        ll t = (bit >> 1);
        REP(j, N)
        {
            ll a = A[j] % bit;
            {
                int ui = getUnder(t - a);
                int ti = getTop(2 * t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
            {
                int ui = getUnder(3 * t - a);
                int ti = getTop(4 * t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
        }
        ans |= ((D[i] % 2) << i);
    }

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

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int n; cin >> n;
    int mod = 1000000007;

    //i個を1個または3個に分割するやり方
    vec dp(n);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 1;
    int dpsum = dp[0] + dp[1] + dp[2];
    FOR(i, 3, n){
        dp[i] = (dpsum - dp[i - 2] + mod) % mod;
        dpsum = (dpsum + dp[i]) % mod;
    }

    int ans = 0;
    REP(i, n){
        //i+1項目から考える
        //i+i項目がn-i以上
        int tmp;
        if(i == n - 1) tmp = n;
        else if(i == n - 2) tmp = n - 1;
        else tmp = i + 2;
        if(i != n - 1) tmp = (tmp * n) % mod;
        if(i < n - 2){
            tmp += (n - 3 - i) * (n - 1);
            tmp %= mod;
        }
        ans += tmp * dp[i];
        ans %= mod;
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int sum_keta(int n){
  if(n==0) return 0;
  return n%10 + sum_keta(n/10);
}
int main(void){
  int N,A,B; cin >> N >> A >> B;
  
  int sum = 0;
  for(int i=1;i<=N;i++){
  	if(A <= sum_keta(i) && sum_keta(i) <= B) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
  	cin>>s;
  	for(int i=0;i<s.size();i++)
  		if(s[i]!=',')
  			cout<<s[i];
  		else
  			cout<<" ";
  	return 0;
}

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


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}
	
int main(void)
{
	int a, b, c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d %d %d",c,a,b);

	return 0;
} 

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func nextInt() int {
	scanner.Scan()

	var i, _ = strconv.Atoi(scanner.Text())

	return i
}

func nextString() string {
	scanner.Scan()

	return scanner.Text()
}

func initScanner() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

type Node struct {
	Point int
}

func NewNode(point int) Node {
	return Node{
		Point: point,
	}
}

func maxInt(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}
func minInt(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func main() {
	initScanner()

	var n = nextInt()

	var nodes = make([]Node, n)
	for i := 0; i < n; i++ {
		nodes[i] = NewNode(nextInt())
	}

	var max = -1

	for c := 1; c < n-1; c++ {
		var sum = 0
		var touched = make([]bool, len(nodes))

		var x = 0

		for {
			var a = (n - 1) - minInt(c*x, n-1)
			var b = a - minInt(c, a)

			if a == 0 || b == 0 {
				break
			}

			// 最後のジャンプ
			if touched[(n - 1 - a)] {
				break
			}

			sum += nodes[n-1-a].Point
			touched[n-1-a] = true

			// 最初のジャンプ
			if touched[a] {
				break
			}
			sum += nodes[a].Point
			touched[a] = true

			max = maxInt(max, sum)
			x++
		}

	}

	fmt.Println(max)
}


Measured memory_bytes: 17152