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

int N;
vector<vector<int>> cap;

template<Flow inf> Flow fordFulkerson(const int &source, const int &sink) {
  vector<int> used(N);
  function<Flow(int, Flow)> dfs = [&](int v, Flow f) -> Flow {
    if (v == sink) return f;
    used[v] = true;
    rep(i, N) {
      if (used[i] || cap[v][i] <= 0) continue;
      Flow d = dfs(i, min(f, cap[v][i]));
      if (d <= 0) continue;
      cap[v][i] -= d;
      cap[i][v] += d;
      return d;
    }
    return 0;
  };
  if (inf == 1) {
    fill(used.begin(), used.end(), false);
    return dfs(source, inf);
  }
  Flow s, f;
  for (s = 0; (f = dfs(source, inf)); s += f) fill(used.begin(), used.end(), false);
  return s;
}

int main() {
  int E, Q;
  cin >> N >> E >> Q;
  cap = vector<vector<int>>(N, vector<int>(N));
  rep(i, E) {
    int f, t;
    cin >> f >> t;
    --f, --t;
    cap[f][t] = cap[t][f] = 1;
  }
  Flow f = fordFulkerson<1000000000>(0, N - 1);
  rep(i, Q) {
    int m, a, b;
    cin >> m >> a >> b;
    --a, --b;
    if (m == 1) {
      cap[a][b] = cap[b][a] = 1;
      f += fordFulkerson<1>(0, N - 1);
    } else {
      if (cap[a][b] != 0) swap(a, b);
      if (cap[a][b] == 0 && fordFulkerson<1>(a, b) == 0) {
        fordFulkerson<1>(N - 1, b);
        fordFulkerson<1>(a, 0);
        f--;
      }
      cap[a][b] = cap[b][a] = 0;
    }
    cout << f << endl;
  }
}



Measured memory_bytes: 3964
#include <stdio.h>
#include <math.h>
#define ll long long

long long calc (long long a, long long b){
    return (a * b) % 2019;
}

int main(){
    ll a, b, min = 1000000000;
    scanf("%lld %lld", &a, &b);
    if (a * b < 2019){
        printf("%lld\n", a * b);
        return 0;
    } else if ((a * b % 2019 == 0) || (floor(a/2019) != floor(b/2019))){
        printf("0\n");
        return 0;
    } else {
        for (long long i = a; i < b; i++) {
            for (long long j = a + 1; j <= b; j++){
                if (calc(i, j) < min)
                    min = calc(i, j);
            }
        }
        printf("%lld\n", min);
        return 0;
    }
}

Measured memory_bytes: 128
from bisect import bisect_left
from collections import deque
N = int(input())
d = deque()

for i in range(N):
    a = int(input())
    n = bisect_left(d, a)
    if n != 0:
        d[n-1] = a
    else:
        d.appendleft(a)
print(len(d))


Measured memory_bytes: 7284
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n = 10000;
    int a[n], b[n];
    repi(i, n, 1)
    {
        a[i] = i * 8 / 100;
        b[i] = i / 10;
    }
    int A, B;
    cin >> A >> B;
    vector<int> candi;
    repi(i, n, 0)
    {
        if (a[i] == A){
            candi.push_back(i);
        }
    }
    for (int e : candi)
    {
        if(b[e] == B){
            cout << e << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<ll>divisor(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(ret.begin(),ret.end());
    return ret;
}

int main(){
    ll n,m;
    cin >> n >> m;
    auto div = divisor(m);
    sort(div.rbegin(),div.rend());
    rep(i,div.size()){
        if(div[i]*n<=m){
            cout << div[i] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3644
n,k = gets.split(" ").map(&:to_i)
hn = gets.split(" ").map(&:to_i)
if n <= k
  p 0
elsif k.zero?
  p hn.inject(&:+)
elsif hn.length == n
  hns = hn.sort{|a, b| b.to_i <=> a.to_i }
  hns.slice!(0..k-1)

  p hns.inject(&:+)
end

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;

void solve() {
	cin >> str;
	N = sz(str);
	int res = inf;
	rep(k, 0, 2) {
		int tmp = 0;
		rep(i, 0, N) {
			tmp += (str[i] == '1') ^ ((k + i) % 2);
		}
		MIN(res, tmp);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;  
  for (int i = 0; i <= N-3; i++) {
    if (S.substr(i, 3) == "ABC") ++ans;
  }
  cout << ans << '\n';
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	ll a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f=5,g=2,goukei=0,goukei2=0,n=0;
	cin>>a;
	for (int A=0;A<a;A++){
		f=5;
		g=2;
		goukei2=0;
		cin>>b>>c>>d>>e;
		goukei=b*d+c*e;
		if (d>=5&&e>=2){
			goukei*=0.8;
			cout<<goukei<<endl;
			continue;
		}
		f-=d;
		g-=e;
		if (f>0)goukei2+=f*b;
		if (g>0)goukei2+=g*c;
		goukei2+=goukei;
		goukei2*=0.8;
		if (goukei>goukei2) cout<<goukei2<<endl;
		else cout<<goukei<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll n,m;cin>>n>>m;
  ll mi=1,ma=n;
  //cin>>n>>m;
  for(int i=0;i<m;i++){
      ll a,b;cin>>a>>b;
      mi=max(mi,a);
      ma=min(ma,b);
  }
  ll ans=ma-mi+1;
  if(ans<0)ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int x3;
int y3;
int z3;
int w3;

void multi( int a, int b, int c, int d, int e, int f, int g, int h );
void get( int* inx3, int* iny3, int* inz3, int* inw3 );

int main( void )
{
	int numOfPear;
	
	int x1;
	int x2;
	int y1;
	int y2;
	int z1;
	int z2;
	int w1;
	int w2;
	
	int out[4];
	
	int i;
	
	while( 1 )
	{
		scanf( "%d", &numOfPear );
		if( numOfPear == 0 )break;
		
		for( i = 0; i < numOfPear; i++ )
		{
			scanf( "%d%d%d%d%d%d%d%d", &x1, &y1, &z1, &w1, &x2, &y2, &z2, &w2 );
			multi( x1, y1, z1, w1, x2, y2, z2, w2 );
			
			get( &out[0], &out[1], &out[2], &out[3] );
			printf( "%d %d %d %d\n", out[0], out[1], out[2], out[3] );
		}
	}
	return (0);
}

void multi( int a, int b, int c, int d, int e, int f, int g, int h )
{
	x3 = (a * e) - (b * f) - (c * g) - (d * h);
	y3 = (a * f) + (b * e) + (c * h) - (d * g);
	z3 = (a * g) - (b * h) + (c * e) + (d * f);
	w3 = (a * h) + (b * g) - (c * f) + (d * e);
}

void get( int* inx3, int* iny3, int* inz3, int* inw3 )
{
	*inx3 = x3;
	*iny3 = y3;
	*inz3 = z3;
	*inw3 = w3;
}

Measured memory_bytes: 600
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 500010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,A,B;
int p[N],q[N];
int fa[N][21],dist[N],deep[N];
struct edge
{
	int next,to,p;
}e[N<<1];
int head[N],cnt,win[N],vis[N];
queue<int>Q;
inline void add_edge(int from,int to,int p){e[++cnt]=(edge){head[from],to,p};head[from]=cnt;}
void dfs(int now,int father)
{
	deep[now]=deep[father]+1;fa[now][0]=father;
	for(register int i=1;i<=20;i++)fa[now][i]=fa[fa[now][i-1]][i-1];
	for(register int i=head[now];i;i=e[i].next)
	{
		if(e[i].to==father)continue;
		dfs(e[i].to,now);
	}
}
void bfs()
{
	Q.push(A);vis[A]=1;dist[A]=1;
	while(!Q.empty())
	{
		int x=Q.front();Q.pop();
		for(register int i=head[x];i;i=e[i].next)
		{
			if(e[i].p&&!vis[e[i].to])
			{
				dist[e[i].to]=dist[x]+1;
				if(dist[e[i].to]<deep[e[i].to]){vis[e[i].to]=1;Q.push(e[i].to);}
			}
		}
	}
}
inline int lca(int u,int v)
{
	if(deep[u]<deep[v])swap(u,v);
	for(register int i=20;i>=0;i--)if(deep[fa[u][i]]>=deep[v])u=fa[u][i];
	if(u==v)return u;
	for(register int i=20;i>=0;i--)
	{
		if(fa[u][i]!=fa[v][i])
		{
			u=fa[u][i],v=fa[v][i];
		}
	}
	return fa[u][0];
}
inline int Dist(int x,int y){return deep[x]+deep[y]-2*deep[lca(x,y)];}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),A=read(),B=read();
	for(register int i=1;i<n;i++)p[i]=read(),q[i]=read();
	for(register int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add_edge(x,y,0);add_edge(y,x,0);
	}
	dfs(B,0);
	for(register int i=1;i<n;i++)
	{
		if(Dist(p[i],q[i])>=3)win[p[i]]=win[q[i]]=1;
		else add_edge(p[i],q[i],1),add_edge(q[i],p[i],1);
	}
	bfs();
	int ans=0;
	for(register int i=1;i<=n;i++)if(win[i]&&vis[i]){puts("-1");return 0;}
	for(register int i=1;i<=n;i++)if(vis[i])ans=max(ans,(deep[i]-1)<<1);
	printf("%d\n",ans);
	return 0;
}


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

int main() {
	int n, m; cin >> n >> m;
	vector <string> s; s.clear();
	for (int i = 0; i < n; i ++) {
		string S; cin >> S;
		S = "#" + S + "#";
		s.push_back(S);
	}
	for (int i = 0; i < m+2; i ++) cout << "#"; 
	cout << endl;
	for (int i = 0; i < n; i ++) cout << s[i] << endl;
	for (int i = 0; i < m+2; i ++) cout << "#"; 
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stack>
#include<stdlib.h>
#include<algorithm>
#include<utility>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<=111)cout<<111<<endl;
	else if(n<=222)cout<<222<<endl;
	else if(n<=333)cout<<333<<endl;
	else if(n<=444)cout<<444<<endl;
	else if(n<=555)cout<<555<<endl;
	else if(n<=666)cout<<666<<endl;
	else if(n<=777)cout<<777<<endl;
	else if(n<=888)cout<<888<<endl;
	else if(n<=999)cout<<999<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    long long H,W;

    while(1){
        
        cin >> H >> W;

        if(H==0 && W==0){
            break;
        }

        for(long long i=1;i<=H;i++){

            for(long long j=1;j<=W;j++){
                cout << "#";
            }

            cout << endl;

        }
        cout << endl;
    }


    return 0;

}


Measured memory_bytes: 3080
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  3 21:15:17 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	bits := [40]int{}
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		for j := uint8(0); j < 40; j++ {
			if a&(1<<j) != 0 {
				bits[j]++
			}
		}
	}

	ans := 0
	count := 0
	for j := len(bits) - 1; j >= 0; j-- {
		n1 := bits[j]
		n0 := N - n1
		m := 1 << uint8(j)
		if n0 > n1 && (count+m) <= K {
			ans += n0 * m
			count += m
		} else {
			ans += n1 * m
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  Node *right, *left, *parent;
  int key;
};

Node *root, *NIL;

Node *find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    cin >> com;
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 21920
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		if(N == 3 || N == 5 || N == 7) System.out.println("YES");
		else System.out.println("NO");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

string divide[4] = { "dream","dreamer","erase","eraser" };

int main() {

	string S;
	cin >> S;

	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

	bool is_possible = true, is_possible2;
	for (int i = 0; i < S.size();) {
		is_possible2 = false;
		for (int j = 0; j < 4; ++j) {
			string d = divide[j];
			if (S.substr(i, d.size()) == d) {
				is_possible2 = true;
				i += d.size();
			}
		}
		if (!is_possible2) {
			is_possible = false;
			break;
		}
	}
	
	string msg = (is_possible) ? "YES" : "NO";
	cout << msg << endl;
}

Measured memory_bytes: 512
h, w = map(int, input().split())
S = [input() for i in range(h)]

for i in range(h):
    l = ''
    for j in range(w):
        if S[i][j] == '#':
            l += '#'
        else:
            l += str(sum([T[max(0, j-1) : min(w, j+2)].count('#') for T in S[max(0, i-1) : min(h, i+2)]]))
    print(l)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstring>
#include<algorithm>

#define pi 2*acos(0.00)
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define null '\0'
#define mx 1000007
#define bdyptb return 0;

using namespace std;
int main()
{
    fastio;
    string s;
    cin>>s;
    ll i,j,k=0,t=0;
    if(s.size()<3)
    {
        cout<<0<<nl;
        bdyptb;
    }
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            k++;            
        }
        else if(s[i]=='B'&& s[i+1]=='C'&& i+1<s.size())
                {t+=k;i++;}
            // swap(s[i],s[i+1]);  swap(s[i+1],s[i+2]);           
            
        else k=0;
    }    
    cout<<t<<nl;

    bdyptb;
}

Measured memory_bytes: 720
import sys
input = sys.stdin.readline
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
l = [[-d[key], key] for key in d]
l.sort()

m = l[0][0]
for v, k in l:
    if v == m:
        print(k.rstrip("\n"))


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


int main(){
  
  long long K, cnt=0, a=0;
  cin>>K;
  
  while(cnt<=100000000){
    cnt++;
    a=(a*10+7)%K;
    if(a==0){
      cout<<cnt<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

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

using namespace std;

int main(){
	string s = (char*)calloc(1001, sizeof(char));
	cin >> s;
	
	if(s.at(s.size()-1) == 's') cout << s << "es";
	else cout << s << "s";
	cout << endl;
	
	
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>

namespace mp = boost::multiprecision;
using cpp_dec_float = mp::number<mp::cpp_dec_float<500>>;

int main() {
  long long a;
  cpp_dec_float b;
  std::cin >> a >> b;
  std::cout << (long long)(a * b) <<  std::endl;
   
}

Measured memory_bytes: 3884
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string  in_boss;
            int in_entotal;
            int[] result;
            in_entotal = int.Parse(Console.ReadLine());
            in_boss  = Console.ReadLine();
            string[] boss_array = in_boss.Split(' ');
            result = new int[in_entotal];
            foreach(string i in boss_array)
            {
                result[int.Parse(i)-1] += 1;
            }
            foreach(int i in result)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 41832
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	cr := make([]int, n-1)
	sr := make([]int, n-1)
	fr := make([]int, n-1)
	for i := range cr {
		fmt.Scan(&cr[i], &sr[i], &fr[i])
	}
	for st := 0; st < n-1; st++ {
		t := 0
		for i := st; i < n-1; i++ {
			if t <= sr[i] {
				t = sr[i] + cr[i]
			} else {
				v := t - sr[i]
				m := v % fr[i]
				if m == 0 {
					t += cr[i]
				} else {
					t += fr[i] - m + cr[i]
				}
			}
		}
		fmt.Println(t)
	}
	fmt.Println(0)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 1000006

using namespace std;

int n,a,b;
long long s[N],t[N];

void work();

int main(){
	scanf("%d%d%d",&a,&b,&n);
	for(int i = 1;i <= a; ++i) scanf("%lld",&s[i]);
	for(int i = 1;i <= b; ++i) scanf("%lld",&t[i]);
	sort(s + 1,s + 1 + a);sort(t + 1,t + 1 + b);
	s[0] = s[a + 1] = t[0] = t[b + 1] = 999999999999;
	while(n--)
		work();
}

void work(){
	int i,j,x,y;
	long long p,ans = 9999999999999999;
	scanf("%lld",&p);
	i = lower_bound(s + 1,s + 1 + a,p) - s;
	j = lower_bound(t + 1,t + 1 + b,p) - t;
	for(int x = i - 1;x <= i; ++x)
		for(int y = j - 1;y <= j; ++y){
			long long sum = abs(s[x] - p) + abs(t[y] - s[x]);
			sum = min(sum,abs(t[y] - p) + abs(s[x] - t[y]));
			ans = min(ans,sum);
		}
	printf("%lld\n",ans);
}


Measured memory_bytes: 6144
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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


class CColon {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    long double PI = 3.14159265358979323846264338327950L;

	void solve(std::istream& in, std::ostream& out) {
        int a,b,h,m;
        in >> a >> b >> h >> m;
        long double rad=PI* 2 * ((long double)h/ 12.0 + ((long double)m/ 60.0) / 12.0 - (long double)m/ 60.0);
        long double rsq= (long double)(a*a+b*b) - (long double)(2 *a*b) *cosl(rad);
        out << setprecision(64) << sqrtl(rsq) << endl;
	}
};


int main() {
    ios::sync_with_stdio(false);
	CColon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
  	cin >> a >> b;
  	cout << (a*3+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadString()
	r := []string{
		"Sunny",
		"Cloudy",
		"Rainy",
	}
	s := 0
	for i := 0; i < len(r); i++ {
		if r[i] == S {
			s = i
			break
		}
	}
	fmt.Println(r[(s+1)%3])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


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

const int MAX = 1000001;
int main() {
	int N, Q, K;
	string S;
	cin >> N >> S >> Q;
	static int sum[MAX];
	sum[0] = 0;
	for (int i = 0;i < N;++ i) sum[i + 1] = sum[i] + (S[i] == 'M' ? 1 : 0);
	
	for (int i = 0;i < Q;++ i) {
		cin >> K;
		int64_t out = 0, D = 0, cnt = 0;
		for (int j = 0;j < K;++ j) {
			if (S[j] == 'D') ++ D;
			else if (S[j] == 'M') cnt += D;
			else if (S[j] == 'C') out += cnt;
		}
		for (int j = K;j < N;++ j) {
			if (S[j - K] == 'D') {
				cnt -= sum[j] - sum[j - K];
				-- D;
			}
			if (S[j] == 'D') ++ D;
			else if (S[j] == 'M') cnt += D;
			else if (S[j] == 'C') out += cnt;
		}
		cout << out << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 5252
import numpy as np
N,M,X= map(int,input().split())
C = [0 for i in range(N)]
A = [[0 for i in range(M+1)] for j in range(N)]
skill = [0 for i in range (M)]
ans = float('inf')
ans_check = 0
for i in range(N):
  A[i] = list(map(int,input().split()))
  C[i] = A[i][0]
A = np.array(A)
for i in range(2 ** N):
 # print(skill)
  skill = np.array([0 for i in range (M)])
  money = 0
  check = 0
  for j in range(N):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      for l in range(M):
        skill[l] += A[j][l+1]
      money += C[j]
  for k in range(M):
    if skill[k]<X:
      check = 1
      
  if check == 0:
    if money <= ans:
      ans = money
      ans_check = 1
  
if ans_check == 0:
  print(-1)
else:
  print(ans)


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

bool solve() {
  string S, T; cin >> S >> T;
  int N = S.size();
  rep(i, 0, N) {
    int len = N - i;
    string t = T.substr(i, len) + T.substr(0, i);
    if(S == t) return true;
  }
  return false;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char a[3];
	int one,three;
	scanf("%s",a);
	one = a[0] - '0';
	three = a[2] - '0';
	if(one == three){
	    printf("Yes\n");
	} else {
	    printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

struct edge{int to,cost;};
int V=10;
vector<edge> G[100010];
ll d[100010];

void dijkstra(int s){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(d,d+V,longinf);
  d[s]=0;
  que.push(pint(0,s));
  
  while(!que.empty()){
    pint p=que.top(); que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(pint(d[e.to],e.to));
      }
    }
  }
}

int h,w;

int main(){
  cin >> h >> w;
  int c[10][10];
  rep(i,10){
    rep(j,10){
      cin >> c[j][i];
    }
  }
  rep(i,10){
    rep(j,10){
      if(i!=j)G[i].push_back({j,c[i][j]});
    }
  }
  dijkstra(1);
  int a[h][w];
  ll ans=0;
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
      if(a[i][j]!=-1)ans+=d[a[i][j]];
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 2816
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class BMakingTriangle {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin>>N;
    vector<int>L(N);
    int ans = 0;
    rep(i, N)cin>>L[i];
    rep(i, N-2){
      REP(j, i+1, N-1){
        REP(k, j+1, N){
          if (L[i] != L[j] and L[j] != L[k] and L[i] != L[k]){
            vector<int> temp = {L[i], L[j], L[k]};
            sort(ALL(temp));
            if (temp[2] < temp[1]+temp[0]){
              ans++;
            }
          }
        }
      }
    }
    cout<<ans<<endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  BMakingTriangle solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    ll a[n], sum = 0, A = 0, B = 0;
    rep(i, n) cin >> a[i], sum -= a[i];
    rep(i, n) {
        ll b;
        cin >> b;
        sum += b;
        if(b < a[i])
            B += a[i] - b;
        else
            A += b - a[i] + 1 >> 1;
    }
    cout << (sum >= A && sum >= B ? "Yes" : "No") << endl;

    return 0;
}

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

					#define pb push_back
					#define cend(s) return cout << s, 0;
					using namespace std;
					typedef long long ll;
					int main()
					{
						int n;
						cin >> n;
						n %= 10;
						if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
							cend("hon");
						if(n == 0 || n == 1 || n == 6 || n == 8)
							cend("pon");
						cend("bon");			
					}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ha = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var h = ha[0];
            var a = ha[1];

            Console.WriteLine(h / a + (h % a != 0 ? 1 : 0));
        }
    }
}

Measured memory_bytes: 28244
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    ll i,n;
    string str="ACL",ans="";
    cin>>n;
    for(i=1; i<=n; i++)ans+=str;
    cout<<ans<<endl;


    return 0;
}








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

int main() {
  int N, M;
  cin >> N >> M;

  int sum = 0; // 合計点を表す変数
  int x;       // 入力を受け取る変数
  int i = 0;   // カウンタ変数

  while (i < M) {
    cin >> x;
    sum += x;
    i++;
  }
  if (N < sum) {
    sum = N + 1;
  }

  cout << N - sum << endl;
}


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

using namespace std;

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

	map < char, char >mps;
	map < char, char >mpt;

	for (int i = 0; (size_t) i < s.size(); i++) {
		auto its = mps.find(s[i]);
		auto itt = mpt.find(t[i]);
		if (its != mps.end() && its->second != t[i]) {
			cout << "No" << endl;
			return 0;
		}
		if (itt != mpt.end() && itt->second != s[i]) {
			cout << "No" << endl;
			return 0;
		}

		mps[s[i]] = t[i];
		mpt[t[i]] = s[i];
	}

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


Measured memory_bytes: 776
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int count=0;
	if(s[0]=='R')
		count=1;
	int ans=0;
	ans=max(ans,count);
	for(int i=1;i<3;i++)
	{
		if(s[i-1]=='R' && s[i]=='R')
			count++;
		else if(s[i-1]!='R' && s[i]=='R')
			count=1;
		else
			count=0;
		ans=max(ans,count);	
	}
	cout<<ans<<"\n";
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

pll conv(ll x){
  ll s,t;
  t = x%10;
  while(x>0){
    if(x<10)
      s = x%10;
    x/=10;
  }

  return pll(s,t);
}


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

  ll n;
  cin >> n;

  map<pll,ll> m;
  for(ll i = 1; i<=n; i++){
    pll re = conv(i);
    m[re] += 1;
  }

  ll ans = 0;
  for(ll i = 1; i<=n; i++){
    pll re = conv(i);
    pll re2;
    re2.FI = re.SE;
    re2.SE = re.FI;
    ans += m[re2];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
s = s[::-1]
ans = 0
cnt = 0
pos = 0
while pos<len(s):
  if s[pos] == "A":
    ans += cnt
    pos += 1
  elif s[pos] == "B":
    cnt = 0
    pos += 1
  elif s[pos:pos+2] == "CB":
    cnt += 1
    pos += 2
  else:
    cnt = 0
    pos += 1
print(ans)

Measured memory_bytes: 42096
N, K = gets.split.map(&:to_i)
S = gets.chomp

white_blocks = []
black_blocks = []

wc = 0
bc = 0

S.each_char do |s|
  if s == '0'
    bc += 1
    white_blocks << ['W', wc] if wc > 0
    wc = 0
  else
    wc += 1
    black_blocks << ['B', bc] if bc > 0
    bc = 0
  end
end

white_blocks << ['W', wc] if wc != 0
black_blocks << ['B', bc] if bc != 0

list = []

if S[0] == '0'
  list = black_blocks.zip(white_blocks).flatten
else
  list = white_blocks.zip(black_blocks).flatten
end

list = list.compact.each_slice(2).to_a

ls = list.size
head = 0
tail = 0

color, val = list[0]
cnt = val
k = color == 'B' ? 1 : 0
ans = cnt

while tail <= head
  ans = cnt if ans < cnt && k <= K

  if head == ls - 1
    c, v = list[tail]
    k -= 1 if c == 'B'
    cnt -= v
    tail += 1
  elsif head < ls - 1 && k <= K
    head += 1
    c, v = list[head]
    k += 1 if c == 'B'
    cnt += v
  elsif tail < ls - 1 && k > K
    c, v = list[tail]
    k -= 1 if c == 'B'
    cnt -= v
    tail += 1
  end
end

puts ans


Measured memory_bytes: 25560
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N; 
  	cin >> N; 
	bool owari = false; 
	for(int i = 1; i <= 3500; i++){
		for(int j = 1; j <= 3500; j++){
			long long int a = (long long) N * i * j;
			long long int b = (long long) 4 * i * j - N * i - N * j; 
			if(b > 0 && a % b == 0){
				cout << i << " " << j << " " << a / b << endl;
				owari = true; 
				break;  
			}
		}
	if(owari){break;}
	}
}

Measured memory_bytes: 256
n=int(input())
I=[int(i) for i in input().split(" ")]
MAX=max(I)
MIN=min(I)

ans=10000000000000000000000000000
for x in range(MIN,MAX+1):
    SUM=0
    for i in I:
        SUM+=(i-x)**2
    if SUM<ans:
        ans=SUM
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()

ll modpow(ll x, ll n, ll mod) {
    ll ans=1;
    for (; n; n/=2) {
        if (n%2) ans=ans*x%mod;
        x=x*x%mod;
    }
    return ans;
}

const ll MOD = 998244353;
const int N = 333;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vll a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int sum = accumulate(all(a), 0);
    vll dp(sum+1);
    dp[0] = 1;
    for (int x:a) {
        vll tmp(sum+1);
        for (int i=0; i<=sum; i++) {
            tmp[i] = 2*dp[i] % MOD;
        }
        for (int i=sum; i>=x; i--) {
            tmp[i] = (tmp[i] + dp[i-x]) % MOD;
        }
        swap(dp, tmp);
    }
    vll dp2(sum+1);
    dp2[0] = 1;
    for (int x:a) {
        for (int i=sum; i>=x; i--) {
            dp2[i] = (dp2[i] + dp2[i-x]) % MOD;
        }
    }
    ll ans = modpow(3, n, MOD);
    for (int x=(sum+1)/2; x<=sum; x++) {
        ans = (ans + MOD - 3*dp[x]%MOD) % MOD;
    }
    if (sum%2==0) {
        ans = (ans + 3*dp2[sum/2]) % MOD;
    }
    cout << ans%MOD << '\n';
}


Measured memory_bytes: 1728
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define maxn 100009
using namespace std;
typedef long long ll;
int n;
ll c,a[maxn],b[maxn],d[maxn],val[maxn],p[maxn],p2[maxn];
int main()
{
    scanf("%d%lld",&n,&c);
    for (int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&b[i]),
	d[i]=c-a[i],val[i]=val[i-1]+b[i];
    for (int i=1;i<=n;i++) p[i]=0,p2[i]=0;
    p[n]=b[n]-d[n];p2[n]=b[n]-d[n]-d[n];
    for (int i=n-1;i>=1;i--)
    p[i]=max(p[i+1],val[n]-val[i-1]-d[i]),
    p2[i]=max(p2[i+1],val[n]-val[i-1]-d[i]-d[i]);
    ll ans=0;
    for (int i=1;i<=n;i++) 
    {
	  ans=max(ans,val[i]-a[i]),
	  ans=max(ans,val[n]-val[i-1]-c+a[i]);
    }
    for (int i=1;i<=n;i++)
    {
      ans=max(ans,val[i]-a[i]-a[i]+p[i+1]);
      ans=max(ans,val[i]-a[i]+p2[i+1]);
	}
	printf("%lld\n",ans);
  return 0;
}

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

long long int a,b,c;
long long int ans;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)
		ans=0;
	else
	{
		long long int ans1=a*b*1;
		long long int ans2=b*c*1;
		long long int ans3=a*c*1;
		ans=min(ans1,ans2);
		ans=min(ans,ans3);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def LI():return list(map(int,input().split()))
def II():return int(input())
def yes():return print("Yes")
def no():return print("No")
INF=float("inf")
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush
from itertools import product, combinations
from functools import reduce, lru_cache
from math import pi, gcd
from decimal import Decimal

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

class Unionfind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

n=II()
mod=10**9+7
print((pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))%mod)

Measured memory_bytes: 70964
#include <iostream>
#include <string>
using namespace std;
int m,n;
string a[100], b[100];
int main(){
cin >> m >> n;
for(int i = 0; i < m; ++i){
cin >> a[i];
}
for(int i = 0; i < n; ++i){
cin >> b[i];
}
bool allok = false;
for(int i = 0; i <= m - n; ++i){
for(int j = 0; j <= m - n; ++j){
bool ok = true;
for(int k = 0; k < n; ++k){
for(int l = 0; l < n; ++l){
if(a[i + k][j + l] != b[k][l]) {ok = false; break;}
}
}
if(ok){allok =true; break;}
}
}
cout << (allok ? "Yes" : "No") << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 998244353;
const double EPS = 1e-14, PI = acos(-1.0);

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    REP(i,n) cin >> x[i] >> y[i];

    VL two(n+1);
    two[0] = 1;
    REP(i,n) two[i+1] = (two[i] * 2) % mod;

    ll ans = (two[n] + mod - 1 - n) % mod;

    VL c(n+1);

    REP(i,n) REP(j,n) {
        if (i == j) continue;
        double theta = atan2(y[j] - y[i], x[j] - x[i]);
        int p = 2;
        REP(k,n){
            if (k == i || k == j) continue;
            double phi = atan2(y[k] - y[i], x[k] - x[i]);
            phi = fabs(phi - theta);
            if (fabs(phi) < EPS || fabs(phi - PI) < EPS) p++;
        }
        c[p]++;
    }

    FOR(x,2,n){
        c[x] /= x * (x-1);
        // cout << c[x] << endl;
        ll tmp = (c[x] * (two[x] + mod - x - 1)) % mod;
        ans = (ans - tmp + mod) % mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    return b>0?gcd(b,a%b):a;
}
ll prime_factor(ll n){
	ll res = 1;
	for(ll i=2;i*i<=n;i++){
	    if(n%i==0) res++;
		while(n%i==0){
			n/=i;
		}
	}
	if(n!=1) res++;
	return res;
}
int main(){
    ll a,b;
    cin>>a>>b;
    ll t=gcd(a,b);
    ll res = 1;
    ll mp=prime_factor(t);
	cout<<mp<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100100;
int A[MAXN], B[MAXN];
ll cnt[10];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    int N;
    cin >> H >> W >> N;
    map<pii, int> mp;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        mp[pii(A[i], B[i])] = 1;
    }
    set<pii> S;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) {
            int y = A[i] - j, x = B[i] - k;
            if (y < 0 || x < 0) continue;
            if (y+2 >= H || x+2 >= W) continue;
            S.insert(pii(y, x));
        }
    }
    for (auto p : S) {
        int y = p.first, x = p.second;
        int tmp = 0;
        for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) {
            if (mp[pii(y+i, x+j)] == 1) tmp++;
        }
        if (!tmp) continue;
        cnt[tmp]++;
    }
    cnt[0] = (H-2) * (W-2);
    for (int i = 1; i <= 9; i++) {
        cnt[0] -= cnt[i];
    }
    for (int i = 0; i <= 9; i++) {
        cout << cnt[i] << endl;
    }
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  ll ans = -INF;

  for (ll i = N; i <= 999; i++) {
    string s = to_string(i);
    if (s[0] == s[1] && s[1] == s[2]) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String s = std.next();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == '#') {
                a[i] = 1;
            } else {
                a[i] = 0;
            }
        }

        long[] dp = new long[n+1];
        for (int i = 0; i < n; i++) {
            dp[i+1] += dp[i] + a[i];
        }

        long min = Long.MAX_VALUE;
        for (int i = 0; i <= n; i++) {
            long left = dp[i];
            long right = (n - i) - (dp[n] - dp[i]);
            min = Math.min(left + right, min);
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 30644