akhauriyash/Code-Regression huggingface dataset:
// C++ program to find the longest repeated
// non-overlapping substring
#include<bits/stdc++.h>
using namespace std;

// Returns the longest repeating non-overlapping
// substring in str
string longestRepeatedSubstring(string str)
{
	int n = str.length();
	int LCSRe[n+1][n+1];

	// Setting all to 0
	memset(LCSRe, 0, sizeof(LCSRe));

	string res; // To store result
	int res_length = 0; // To store length of result

	// building table in bottom-up manner
	int i, index = 0;
	for (i=1; i<=n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			// (j-i) > LCSRe[i-1][j-1] to remove
			// overlapping
			if (str[i-1] == str[j-1] &&
				LCSRe[i-1][j-1] < (j - i))
			{
				LCSRe[i][j] = LCSRe[i-1][j-1] + 1;

				// updating maximum length of the
				// substring and updating the finishing
				// index of the suffix
				if (LCSRe[i][j] > res_length)
				{
					res_length = LCSRe[i][j];
					index = max(i, index);
				}
			}
			else
				LCSRe[i][j] = 0;
		}
	}

	// If we have non-empty result, then insert all
	// characters from first character to last
	// character of string
	if (res_length > 0)
		for (i = index - res_length + 1; i <= index; i++)
			res.push_back(str[i-1]);

	return res;
}

// Driver program to test the above function
int main()
{
	int n; cin>>n;
	string str; cin>>str;
	cout << longestRepeatedSubstring(str).size() << endl;
	return 0;
}


Measured memory_bytes: 97920
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

struct UnionFind {
  std::vector<int> parent;
  int __size;
  UnionFind(int size_) : parent(size_, -1), __size(size_) {}
  void unite(int x, int y) {
    if ((x = root(x)) != (y = root(y))) {
      if (parent[y] < parent[x]) std::swap(x, y);
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  int size(int x) { return -parent[root(x)]; }
  int size() { return __size; }
};


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

  long long n, k, l;
  cin >> n >> k >> l;

  UnionFind tree1(n);
  for (int i = 0; i < k; i++) {
    int p, q; cin >> p >> q;
    p--; q--;
    tree1.unite(p, q);
  }

  UnionFind tree2(n);
  for (int i = 0; i < l; i++) {
    int r, s; cin >> r >> s;
    r--; s--;
    tree2.unite(r, s);
  }
  map< pair<int, int>, int > mp;

  for (int i = 0; i < n; i++) {
    int root1 = tree1.root(i);
    int root2 = tree2.root(i);
    mp[make_pair(root1, root2)]++;
  }

  for (int i = 0; i < n; i++) {
    int root1 = tree1.root(i);
    int root2 = tree2.root(i);
    cout << mp[make_pair(root1, root2)] << "\n";
  }

  return 0;
}


Measured memory_bytes: 13568
import java.util.*;

public class Main{
	static HashMap<String,ArrayList<String>> map;
	static ArrayList<ArrayList<String>> ans;

	static void solve(int rem,String s,ArrayList<String> al){
		if(rem == 0){
			ans.add(al);
			return;
		}

		for(String key : map.keySet()){
			if(s.startsWith(key)){
				String ns = s.substring(key.length());

				for(String val : map.get(key)){
					ArrayList<String> nal = new ArrayList<String>(al);
					nal.add(val);
					solve(rem-key.length(),ns,nal);
				}
			}
		}
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] b = new int[128];
		b['a'] = b['b'] = b['c'] = 2;
		b['d'] = b['e'] = b['f'] = 3;
		b['g'] = b['h'] = b['i'] = 4;
		b['j'] = b['k'] = b['l'] = 5;
		b['m'] = b['n'] = b['o'] = 6;
		b['p'] = b['q'] = b['r'] = b['s'] = 7;
		b['t'] = b['u'] = b['v'] = 8;
		b['w'] = b['x'] = b['y'] = b['z'] = 9;

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			map = new HashMap<String,ArrayList<String>>();

			for(int i=0;i<n;i++){
				String s = sc.next();
				String digit = "";
				for(char ch : s.toCharArray()){
					digit += b[ch];
				}
				if(!map.containsKey(digit)) map.put(digit,new ArrayList<String>());
				map.get(digit).add(s);
			}

			String s = sc.next();

			ans = new ArrayList<ArrayList<String>>();
			solve(s.length(),s,new ArrayList<String>());

			for(ArrayList<String> al : ans){
				System.out.println(al.toString().replaceAll("\\[|\\]|,","") + ".");
			}
			System.out.println("--");
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int gcd(int a,int b){//ユークリッドの互除法
  if(a<b) swap(a,b);
  while(b){
    a %= b;
    swap(a,b);
  }
  return a;
}
signed main(){
  int n,x;
  cin >> n >> x;
  vi a(n);
  REP(i,n){
    int tmp;
    cin >> tmp;
    a[i] = abs(x-tmp);
  }
  int ans = a[0];
  REP(i,n) ans = gcd(ans,a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

	int cnt = 0;
	int res = 0;
	for(char& c : s) {
		switch (c)
		{
			case 'A':
			case 'C':
			case 'G':
			case 'T':
				cnt++;
				break;
		
			default:
				cnt = 0;
				break;
		}
		res = max(res, cnt);
	}
	
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double acc = 1e-6;

main(){
    int n,m;
  cin >> n >> m;
  int a[n];
  double tot_v=0.0;
  
  for(int i=0;i<n;i++){
    cin >> a[i] ;
    tot_v+=a[i] ;
  }
  tot_v=tot_v/(4.0*m) ;
  int count = 0;
  for(int i=0;i<n;i++)
     if( ceil(tot_v) <= a[i] )
       count++;
    
   if(count >= m)
     	cout << "Yes\n" ;
    else cout << "No\n" ;
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
  	cin>>N;
  	ll a[N+10];
  	for(ll i=0; i<N; i++){
		cin>>a[i];
    }
  	sort(a,a+N);
  	cout<<a[N-1]-a[0]<<endl;

}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;

int main()
{
    set<int> mp;
    FOR(i, 10, 1)
    {
        FOR(j, 10, 1)mp.insert(i * j);
    }
    int i; cin >> i;
    if(mp.count(i))cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long np = B - A + 1;
        if (N == 1) {
            if (A != B) System.out.println(0);
            else System.out.println(np); // 1
            return;
        }
        if (A > B)  {
            System.out.println(0);
            return;
        }

        long ans = (N - 2) * (B - A) + 1;
        System.out.println(ans);


        return;
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
bool isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll t,n,b,m;
	string s,s1,s2;
	cin>>s;
	s1="";s2="";
	n=s.size();
	for(ll i=0;i<(n-1)/2;i++)s1+=s[i];
	for(ll i=((n+3)/2)-1;i<n;i++)s2+=s[i];
	if(!isPalindrome(s))cout<<"No\n";
	else if(!isPalindrome(s1)){cout<<"No\n";}
	else if(!isPalindrome(s2)){cout<<"No\n";}
	else cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=15;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
vector<int> g[N];
ll ans=0,n,m;
int vis[N];
void dfs(int u)
{
    int num=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
            num++;
    }
    if(num==n)
        ans++;
    for(int i:g[u])
    {
        if(!vis[i])
        {
            vis[i]=1;
            dfs(i);
            vis[i]=0;
        }
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vis[1]=1;
    dfs(1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
#define int long long
	long long n, w;
	cin >> n >> w;
	vector<pair<int,int>> nya;
	REP(i, n) {
		int a,b;
		cin >> a >> b;
		nya.push_back(make_pair(a,b));
	}
	while (nya.size() != 40) {
		nya.push_back(make_pair(0, 0));
	}
	vector<pair<int,int>> a, b;
	for (int i = 0;i < 1048576;++i) {
		int now = i;
		int volume = 0;
		int value = 0;
		for (int q = 0;now != 0;++q) {
			if (now % 2 == 1) {
				volume += nya[q].second;
				value += nya[q].first;
			}
			now /= 2;
		}
		a.push_back(make_pair(volume, value));
	}
	for (int i = 0;i < 1048576;++i) {
		int now = i;
		int volume = 0;
		int value = 0;
		for (int q = 20;now != 0;++q) {
			if (now % 2 == 1) {
				volume += nya[q].second;
				value += nya[q].first;
			}
			now /= 2;
		}
		b.push_back(make_pair(volume, value));
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int b_itr = b.size() - 1;
	for (int i = 1;i < a.size();++i) {
		a[i].second = max(a[i].second, a[i - 1].second);
		b[i].second = max(b[i].second, b[i - 1].second);
	}
	int ans = 0;
	for (int i = 0;i < a.size();++i) {
		while (b_itr >= 0&&a[i].first + b[b_itr].first > w) {
			b_itr--;
		}
		if (b_itr == -1) break;
		ans = max(ans, a[i].second + b[b_itr].second);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

void yes() {
    cout << "Yes\n";
    exit(0);
}

void no() {
    cout << "No\n";
    exit(0);
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    int a[N];
    cin >> n;
    int mn = n, mx = 1;
    forn(i, 1, n) {
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    if (mn < mx - 1) no();
    if (mn == mx) {
        if (mn == n - 1) yes();
        if (1 <= mn && mn <= n / 2) yes();
        no();
    }
    else {
        int cn = 0, cx = 0;
        forn(i, 1, n)
            if (a[i] == mn)
                ++cn;
            else
                ++cx;
        if (cn + 1 <= mx && mx <= cn + cx / 2) yes();
        else no();
    }

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
   
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
   
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 200;
const int ll mod = 1e9 + 7;
int main ()
{
    data();          
	ll n;
	cin >> n;
	if (n % 1000)
	{
		cout << 1000 - (n % 1000);
	}   
	else {
		cout << 0;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    int x, y;
    cin >> x >> y;
    int t, k=x;
    bool ans{false};
    for (t=0; t<=x; ++t, --k) {
        if ((t*2 + k*4) == y) ans = true;
    }
    cout << (ans?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<string,string> P;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  string lstr=s.substr(0,n),rstr=s.substr(n,n);
  map<P,ll> mp;
  for(int i=0;i<(1<<n);i++){
    string ks,k2;
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==1){
        ks.push_back(lstr[j]);
      }
    }
    for(int j=n-1;j>=0;j--){
      if(((i>>j)&1)==0){
        k2.push_back(lstr[j]);
      }
    }
    P p=P(ks,k2);
    auto itr=mp.find(p);
    if(itr!=mp.end()) mp[p]++;
    else mp[p]=1;
  }
  ll ans=0;
  for(int i=0;i<(1<<n);i++){
    string kr,k2;
    for(int j=n-1;j>=0;j--){
      if(((i>>j)&1)==1) kr.push_back(rstr[j]);
    }
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==0) k2.push_back(rstr[j]);
    }
    P p=P(kr,k2);
    auto itr=mp.find(p);
    if(itr!=mp.end()){
     ans+=mp[p];
     //cout<<mp[kr]<<" "<<kr<<endl;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 46080
import sys
from collections import deque

H,W=map(int, raw_input().split())
A=[ list( sys.stdin.readline().strip())  for i in range(H) ]


D=[ (-1,0),(1,0),(0,1),(0,-1) ]
K=[ [ float("inf") for j in range(W) ] for i in range(H)  ]  #Kyori

q=deque()

for i in range(H):
	for j in range(W):
		if A[i][j]=="#":
			q.append( (i,j) )
			K[i][j]=0


while q:
	h,w=q.popleft()
	for dx,dy in D:
		if 0<=h+dx<H and 0<=w+dy<W and K[h+dx][w+dy]>K[h][w]+1:
				K[h+dx][w+dy]=K[h][w]+1
				q.append( (h+dx,w+dy) )	

ans=0
for x in K:
	ans=max(ans, max(x) )
print ans


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

int main() {
	int n;
	cin >> n;
	double *x;
	double *y;
	x = new double[n];
	y = new double[n];

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

	double d[4]={};
	for(int p=1; p<=3; p++){
		for(int i=0; i<n; i++){
			d[p] += pow(fabs(x[i]-y[i]),p);
		}
		d[p] = pow(d[p],1.0/p);
	}


	for(int i=0; i<n; i++){
		if(d[0]<fabs(x[i]-y[i])){
			d[0]=fabs(x[i]-y[i]);
		}
	}

	printf("%.5f\n",d[1]);
	printf("%.5f\n",d[2]);
	printf("%.5f\n",d[3]);
	printf("%.5f\n",d[0]);


    return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> v_x;
  v_x.push_back(x);
  REP(i,n){
    cin >> x;
    v_x.push_back(x);
  }
  SORT(v_x);
  int ans;
  int s;
  REP(i,n){
    s = v_x[i+1] - v_x[i];
    if (i==0){
      ans = s;
    }else{
      ans = gcd(s,ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.Sequence as Sq

main = do
    n <- readLn :: IO Int
    ab <- replicateM (n-1) $ do
        [a,b] <- map read . words <$> getLine
        return (a-1,b-1)
    cs <- sortOn Down . map read . words <$> getLine :: IO [Int]

    let edge = V.create $ do
            vec <- VM.replicate n []
            forM_ ab $ \(a,b) -> do
                VM.modify vec (a:) b
                VM.modify vec (b:) a
            return vec
    
    let ans = sum $ tail cs
    let sq = Sq.fromList cs
    let result = VU.create $ do
            vec <- VUM.replicate n (0 :: Int)
            let go Sq.Empty _ = return ()
                go ((par,this) Sq.:<| qs) (x Sq.:<| xs) = do
                    VUM.write vec this x
                    let qs' = foldl (Sq.|>) qs $ map (\x -> (this,x)) $ filter (/= par) (edge V.! this)
                    go qs' xs
            go (Sq.singleton (0,0)) sq
            return vec
    print ans
    VU.forM_ result print

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

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
  x %= MOD;
  if(n == 0) return 1; //再帰終了

  else if(n % 2 == 1){
    return  (x * modpow(x, n-1)) % MOD; //nが奇数ならnを1ずらす
  }else{
    return  modpow((x*x) % MOD, n/2) % MOD; //nが偶数ならnは半分になる
  }
}

ll comb(ll n, ll k){
  ll x = 1;
    for(int i=n-k+1; i<=n; i++) {
        x = x*i%MOD;
    }

    ll y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll all = modpow(2, n)-1;
  ll aa =comb(n, a);
  ll bb = comb(n, b);
  ll ans = (all - aa - bb) % MOD;
  while(ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]
dp[0] = 0
for i in range(1, N):
    if (dp[i] > dp[i-1] + abs(h[i] - h[i-1])):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    if i > 1:
        if (dp[i] > dp[i-2] + abs(h[i] - h[i-2])):
            dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])

Measured memory_bytes: 13928
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
        Queue<long> queue = new Queue<long>();
        queue.Enqueue(a[0]);
        long res = 0;
        foreach (var item in a.Skip(1))
        {
            res += queue.Dequeue();
            queue.Enqueue(item);
            queue.Enqueue(item);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 56044
#include <bits/stdc++.h>
using namespace std;
const int maxval = 100 * 1000;
const int INF = (int)1e9 + 100; // should be more than W

int n, W;
int weight[101];
int value[101];

int dp[101][maxval + 1];

void solve () { // bottom-up
	// dp(i, v) = min weight needed to make exact! value v from objects [0, i] 
	for (int v = 0; v <= maxval; v++)
		dp[0][v] = INF;
	for (int i = 0; i < n; i++)
		dp[i][0] = 0; // 0 weight needed to make 0 value
	dp[0][value[0]] = weight[0];
	for (int i = 1; i < n; i++) {
		for (int v = 1; v <= maxval; v++) {
			dp[i][v] = dp[i - 1][v];
			if (value[i] <= v) {
				if (dp[i - 1][v - value[i]] != INF) {
					dp[i][v] = min(dp[i][v], weight[i] + dp[i - 1][v - value[i]]);
				}
			}
		}
	}
	for (int v = maxval; v >= 0; v--)
		if (dp[n - 1][v] <= W) {
			cout << v << "\n";
			break;
		}
/*	for (int i = 0; i < n; i++) {
 		for (int v = 0; v < 20; v++) {
 			if (dp[i][v] == INF)
 				cout << "INF ";
			else
				printf("%3d ", dp[i][v]);
		}
		cout << "\n";
	}
*/	return;
}

int main () {
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> weight[i] >> value[i];
	solve();
	return 0;
}

Measured memory_bytes: 39296
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  int a[n];
  REP(i,n){cin >> a[i]; a[i]--;}
  bool used[n];
  fill(used,used+n,false);
  int num = 0;
  int cnt = 1;
  while(true){
    used[num] = true;
    if(a[num]==1){cout << cnt << endl; break;}
    if(used[a[num]]){cout << -1 << endl; break;}
    num = a[num];
    cnt++;
  }
  return 0;
}


Measured memory_bytes: 768
n, k = map(int,input().split())
n_list = [0 for i in range(10**5)]

for i in range(n):
    a, b = map(int,input().split())
    n_list[a-1] += b

temp = 0

for i in range(len(n_list)):
    temp += n_list[i]
    if temp >= k:
        print(i+1)
        break


Measured memory_bytes: 11732
N = gets.to_i
B = gets.split(' ').map(&:to_i)
anser = Array.new(N, 1000000)
index = 0

B.each do |num| 
  anser[index] = [anser[index], num].min
  anser[index+1] = [anser[index+1], num].min
  index += 1
end

puts anser.inject(:+)


Measured memory_bytes: 1788
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int A, B;
	cin >> A;

	co(bool(A ^ 1));


	Would you please return 0;
}

Measured memory_bytes: 3648
A,B,C,X,Y = map(int,input().split())
l = []
for i in range(max(X,Y)+1):
    T = i * C * 2
    if i < X: 
        T += (X-i)*A
    if i < Y:
        T += (Y-i)*B
    l.append(T)
l.sort()
print(l[0])

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	long long x_curr, x_prev, r, D, x_2000;
	cin >> r >> D >> x_2000;
	x_curr = x_prev = x_2000;
	for (int i = 1; i <= 10; ++i){
		x_curr = 1LL * r * x_prev - D;
		x_prev = x_curr;
		cout << x_curr << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int f;
  f = (S.size()-1)/2;
  string substr = S.substr(0,f);
  string rsubstr;
  rsubstr = substr;
  
  string substr2 = S.substr(f+1,f);
  string rsubstr2;
  rsubstr2 = substr2;
  
  reverse(rsubstr.begin(), rsubstr.end());
  
  if(rsubstr == substr && rsubstr2 == substr2 && rsubstr == rsubstr2)  
  cout << "Yes" <<endl;
  
  else
    cout << "No" << endl;
}

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

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

    vector<int> a(n+1),b(n);
    for ( int i = 0 ; i < n+1 ; i++ ){
        cin >> a.at(i);
    }
    for ( int i = 0 ; i < n ; i++ ){
        cin >> b.at(i);
    }
    int64_t cnt = 0;
    for ( int i = 0 ; i < n ; i++ ){
        int mons = 0;
        if (a.at(i) >= b.at(i)) mons = b.at(i);
        else{
            if ( a.at(i) + a.at(i+1) >= b.at(i) ) {
                mons = b.at(i);
                a.at(i+1) = a.at(i) + a.at(i+1) - b.at(i);
            }
            else{
                mons = a.at(i) + a.at(i+1);
                a.at(i+1) = 0;
            }
        }
        cnt += mons;  
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.Scanner;
 
class Main {
    	public static void main(String[] args) {
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine();
        	String str2 = sc.nextLine();
        	String str3 = str + str;
        	if (str3.contains(str2)) {
            		System.out.println("Yes");
        	}else{
            		System.out.println("No");
        	}
    	}
}

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

int main()
{
    int a;
    string b;
    cin>>b;
    for(int i=0; i<b.size()-1; i++)
    {
        if(b[i]==b[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(b[i]==b[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n=3;
ll c[3][3];

int main(){
	rep(i,n)rep(j,n)cin>>c[i][j];
  rep(i,n){
    set<ll> st;
    rep(j,n){
      st.insert(c[i][j]-c[(i+1)%n][j]);
    }
    if(st.size()>1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
left = [0]
for i in range(N):
    if S[i] == "W":
        left.append(left[-1]+1)
    else:
        left.append(left[-1])
right = [0]
for i in range(N):
    if S[-i-1] == "E":
        right.append(right[-1]+1)
    else:
        right.append(right[-1])
ans = N-1
for i in range(N):
    ans = min(ans,left[i]+right[N-i-1])
print(ans)

Measured memory_bytes: 18152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, C;
  cin >> N >> C;
  Graph D(C, vi(C));
  rep(i,C) rep(j,C) cin >> D[i][j];
  Graph G(3, vi(C, 0));
  rep(i,N) {
    rep(j,N) {
      int color; cin >> color;
      ++G[(i+j)%3][--color];
    }
  }

  Graph cost(3, vi(C, 0));
  rep(i,3) rep(y,C) rep(x,C) cost[i][y] += G[i][x] * D[x][y];

  int ans = 3e8;
  rep(i,C) {
    rep(j,C) {
      if (i == j) continue;
      rep(k,C) {
        if (k == i || k == j) continue;
        ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
      }
    }
  }

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


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'I') {
            cnt++;
        }
        else {
            cnt--;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
		ll n;
		cin>>n;
		ll sum=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				for(int k=1;k<=n;k++)
				{
					if(i==1||j==1||k==1)
						sum+=1;
					else
					sum+=__gcd(i,__gcd(j,k));
				}
			}

		}
			cout<<sum<<endl;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TravelingPlan solver = new TravelingPlan();
        solver.solve(1, in, out);
        out.close();
    }

    static class TravelingPlan {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n + 2];
            long distance = 0;

            for (int i = 1; i <= n; i++) {
                int aa = in.nextInt();
                a[i] = aa;
                distance += Math.abs(a[i] - a[i - 1]);
            }
            distance += Math.abs(a[n]);
            a[n + 1] = 0;

            for (int i = 1; i <= n; i++) {
                long result = distance;
                result -= Math.abs(a[i] - a[i - 1]);
                result -= Math.abs(a[i + 1] - a[i]);
                result += Math.abs(a[i + 1] - a[i - 1]);
                out.println(result);
            }
        }

    }
}



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

using namespace std;

bool check(const char& a, const char& b){
  if(a=='A') return (b=='B' || b=='D');
  if(a=='B') return (b=='A' || b=='C' || b=='E');
  if(a=='C') return (b=='B' || b=='F');
  if(a=='D') return (b=='A' || b=='E' || b=='G');
  if(a=='E') return (b=='B' || b=='D' || b=='F' || b=='H');
  if(a=='F') return (b=='C' || b=='E' || b=='I');
  if(a=='G') return (b=='D' || b=='H');
  if(a=='H') return (b=='E' || b=='G' || b=='I');
  if(a=='I') return (b=='F' || b=='H');
}

bool solve(const string& s){
  for(int i=1; i<s.size(); ++i){
    if(!check(s[i-1], s[i])) return false;
  }
  return true;
}

int main(){
  string s;
  while(cin >> s){
    if(solve(s)) cout << s << endl;
 }
  return 0;
}

Measured memory_bytes: 1172
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------

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

    reverse(all(a));

    ll mi = 2;
    ll ma = 2;
    for(int i = 0; i < k; i++){
        //cout << i << " " << mi << " " << ma << endl;
        if((ma / a[i]) - ((mi - 1) / a[i]) <= 0){
            cout << -1 << endl;
            return 0;
        }

        mi = a[i] * ((mi - 1) / a[i] + 1);
        
        ma = a[i] * (ma / a[i] + 1) - 1;
    }

    cout << mi << " " << ma << endl;


}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll gcd(ll a, ll b){if (b == 0) return a; return gcd(b, a % b);}
ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}
int n;
vi a;
int main() {
    ll ans=0;
    cin>>n;
    a.resize(n);
    REP(i,n)
        cin>>a[i];

    //sort(a.begin(), a.end());
    
    REP(i,n){
        ans += a[i]-1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

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

    int l,r;
    l=0;
    r=s.length()-1;

    int ans = 0;
    while(l<r)
    {
        if (s[l]==s[r])
        {
            l=l+1;
            r=r-1;
        }
        else
        {
            if (s[l]=='x')
            {
                l=l+1;
                ans++;
            }
            else if (s[r]=='x')
            {
                r=r-1;
                ans++;
            }
            else
            {
                ans = -1;
                break;
            }
        }
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-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;
}



int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    unordered_map<ll,ll> m;
    ll sum=0;
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        m[A[i]]++;
        sum+=A[i];
    }

    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
        ll b=B[i];
        ll c=C[i];
        ll tmp_sum=0;
        m[c] += m[b];
        // sum = sum - m[b]*b + m[c]*c - m[b]*c;
        sum = sum - m[b]*b + m[b]*c;
        cout << sum << endl;
        m[b] = 0;
    }

    return 0;
}


Measured memory_bytes: 9440
s=readline()

function CF(S::ASCIIString)
hantei1=false
hantei2=false
for i in 1:length(s)
    hantei1=hantei1?true:is(s[i],'C')
    hantei2=hantei1?(hantei2||is(s[i],'F')):false
end
return hantei2?"Yes":"No"
end

println(CF(s))

Measured memory_bytes: 98660
#include<stdio.h>

int main()
{
  int x, y;
  scanf("%d %d", &x, &y);
  
  if (y % 2 != 0) {
    // 足の数が奇数なら不可
    puts("No\n");
    return 0;
  }
  
  if (y > 4 * x) {
    // 全て鶴と仮定したときよりも足の数が多いのは不可
    puts("No\n");
    return 0;
  }
  
  if (y < 2 * x) {
    // 全て亀と仮定したときよりも足の数が少ないのは不可
    puts("No\n");
    return 0;
  }
  
  // 足の数が偶数で多すぎず少なすぎなければ可
  puts("Yes\n");
  return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    vector<vector<bool>> bingo(3, vector<bool>(3, false));
    rep(i, n) rep(j, 3) rep(k, 3) {
        if(a[j][k] == b[i]) bingo[j][k] = true;
    }

    // 縦横チェック
    rep(j, 3) {
        bool flag = true;
        rep(k, 3) {
            if(!bingo[j][k]) {
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(j, 3) {
        bool flag = true;
        rep(k, 3) {
            if(!bingo[k][j]){
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    // 斜めチェック
    if(bingo[0][0] && bingo[1][1] && bingo[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[0][2] && bingo[1][1] && bingo[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }



    cout << "No" << endl;

    return 0;
}



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

int kaizyo(int i){
    if(i==0){
        return 1;
    }
    int s=kaizyo(i-1);
    return s*i;
}

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    vector<int> q(N);
    for(int i=0;i<N;i++){
        cin >> q[i];
    }

    int sum=0;

    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        if(p[j]>p[i]){
          p[j]=p[j]-1;
        }
        if(q[j]>q[i]){
          q[j]=q[j]-1;
        }
      }
      sum=sum+(p[i]-q[i])*kaizyo(N-i-1);
    }
  
    if(sum>0){
      cout << sum << endl;
    }
    else{
      cout << -sum << endl;
    }
    
 
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	s = sum(v)
	t = sum(v[1::2])
	x = [0] * n
	# print(s, t)
	x[0] = s - 2 * t
	for i in range(1, n):
		x[i] = 2 * v[i-1] - x[i-1]
	for i in range(n):
		print("{} ".format(x[i]), end='')
	print("")


if __name__ == '__main__':
	main()


Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	cout << (s.find("7") != string::npos ? "Yes" : "No");
	
}

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

int main(){
  int x;
  cin >> x;
  int ans=0;
  for(int i=1;i<=x;i++){
    int d=i;
    for(int r=1;r<=x;r++){
      d=d*i;
      if(d<=x){ans=max(ans,d);}
      if(d>x){break;}
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
r,c = map(int,input().split())
table = [[0]*(c+1) for i in range(r+1)]

for i in range(r):
    table[i] = list(map(int,input().split()))
    table[i].append(sum(table[i]))
    for j in range(c+1):
        table[r][j] += table[i][j]

for i in range(r+1):
    for j in range(c+1):
        if(j == c):
            print("%d" %(table[i][j]),end="")
        else:
            print("%d " %(table[i][j]),end="")
    print()


Measured memory_bytes: 6212
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r < 0 || y - r < 0 || x + r > W || y + r > H){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
from collections import defaultdict
import queue

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

class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b, w):
        self.graph[a].append([b, w])

    def get_nodes(self):
        return self.graph.keys()

class BFS(object):
    def __init__(self, graph, N):
        self.g = graph.graph
        self.dist = [0] * (N + 1)
        self.visit = [0] * (N + 1)
        self.Q = queue.Queue()
        self.Q.put(1)

        while not self.Q.empty():
            v = self.Q.get()
            for i, w in self.g[v]:
            	if self.visit[i] == 0:
            		self.dist[i] = self.dist[v] + w
            		self.Q.put(i)
            		self.visit[i] = 1

    def weight(self):
        return self.dist

N = int(input())
G = Graph()
for i in range(N - 1):
    u, v, w = getlist()
    G.add_edge(u, v, w)
    G.add_edge(v, u, w)

XX = BFS(G, N)
ans = XX.weight()
for i in range(1, N + 1):
	if ans[i] % 2 == 0:
		print(0)
	else:
		print(1)

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

using namespace std;

const int MAX_N = 2e5 + 5;

int arr [MAX_N];

int enters [MAX_N];
int exits [MAX_N];
void step (int n) {
  for (int i = 0; i < n; i++) {
    enters[max(0, i - arr[i])]++;
    exits[min(n - 1, i + arr[i])]++;
  }

  int cur = 0;
  for (int i = 0; i < n; i++) {
    cur += enters[i];
    arr[i] = cur;
    cur -= exits[i];
  }

  for (int i = 0; i < n; i++) {
    enters[i] = 0;
    exits[i] = 0;
  }
}

bool full (int n) {
  for (int i = 0; i < n; i++) {
    if (arr[i] != n) return false;
  }
  return true;
}

int main () {
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  for (int i = 0; i < k; i++) {
    step(n);
    if (full(n)) break;
  }

  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 6012
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)


template< typename T >
struct edge {
  ll src, to;
  T cost;

  edge(ll to, T cost) : src(-1), to(to), cost(cost) {}

  edge(ll src, ll to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator ll() const { return to; }
};

template< typename T1 >
using Edges = vector< edge< T1 > >;
template< typename T2 >
using WeightedGraph = vector< Edges< T2 > >;
using UnWeightedGraph = vector< vector< ll > >;
template< typename T3 >
using Matrix = vector< vector< T3 > >;

struct Bipartite_Matching{
  vector< vector< ll > > graph;
  vector< ll > match, alive, used;
  ll timestamp;

  Bipartite_Matching(ll n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }

  void add_edge(ll u, ll v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(ll v)
  {
    used[v] = timestamp;
    for(ll i = 0; i < graph[v].size(); i++) {
      ll u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }

  ll bipartite_matching()
  {
    ll ret = 0;
    for(ll i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,n;
    cin>>x>>y>>n;
    vector<vector<ll>> a;
    vector<ll> b;
    Bipartite_Matching s = {x+y};
    FOR(i,0,n){
      ll in1,in2;
      cin>>in1>>in2;
      in2 += x;
      s.add_edge(in1,in2);
    }
    cout<<s.bipartite_matching()<<endl;
}



Measured memory_bytes: 3392
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<(min(B,D)-max(A,C)<=0?0:min(B,D)-max(A,C))<<endl;
}

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

int main(){

    string S,Z;
    bool ok = true;
    cin >> S >> Z;
    for(int i=0;i<S.length();i++){

        if (S[i] != Z[i]){
            ok = false;
            break;
        }

    }

    cout <<(ok ? "Yes" : "No") << endl;


}

Measured memory_bytes: 3592