akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	for i := 1; i < 10; i++ {
		if n%i == 0 && n/i < 10 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Fprintln(writer, "No")
	writer.Flush()
}


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

int main() {
	int n,m,sm = 0;
 	cin >> n;
	vector<int> t(n,0);
	for(int i = 0;i < n;i++)
	{
		cin >> t.at(i);
		sm += t.at(i);
	}
	cin >> m;
	vector<int> p(m,0),x(m,0);
	for(int i = 0;i < m;i++)
	{
		cin >> p.at(i) >> x.at(i);
		cout << sm - (t.at(p.at(i) - 1) - x.at(i)) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//Templates
//--------------------------------------------
template <typename T>
void cpmt(T *a,T *b,size_t size_a1,size_t size_a2){
  REP(i,size_a1){
    REP(j,size_a2){
      a[i][j] = b[i][j];
    }
  }
}

template <typename T>
void showmat(vector<vector<T>> a,size_t size_a1,size_t size_a2){
  REP(i,size_a1){
    REP(j,size_a2){
      cerr << a[i][j];
    }
    cerr << endl;
  }  
}


//Greatest Common Devider
LL gcd(LL a,LL b){
  if(b == 0) return a;
  return gcd(b,a%b);
}
//------------------------------------------
//Least Common Multiple
//Must be used with GCD
LL lcm(LL a,LL b){
  LL g = gcd(a,b);
  return a / g * b;
}

//grobal var
//------------------------------------------
const int MAX=500;

 
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,M;
  while(cin >> N >> M){
    int ans=0;
    vector<vector<bool>> graph(N,vector<bool>(M,false));
    REP(i,M){
      int a,b;
      cin >> a >> b;
      a--;
      b--;
      graph[a][b]=graph[b][a]=true;
    }
    VI arr(N);
    REP(i,N){
      arr[i]=i;
    }
    do{
      ans++;
      FOR(i,1,N){
        if(!graph[arr[i-1]][arr[i]]){
          ans--;
          break;
        }
      }
    }while(next_permutation(arr.begin()+1,arr.end()));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long int ara[200];

long long int comp(long long int a, long long int n)

{
    long long int i,b = 0;
    for(i = 0; i < n; i++){
        b += ((ara[i]-a)*(ara[i]-a));
    }
    return b;
}

int main(void)

{
    long long int n,a = 0,i,dis = INT_MAX, b = 440,c;
    cin>>n;
    for(i = 0; i < n; i++){
        cin>>ara[i];
        if(ara[i] > a)
            a = ara[i]; //boro
        if(ara[i] < b)
            b = ara[i]; //choto
    }
    for(i = b; i <= a; i++){
        c = comp(i, n);
        if(c < dis){
            dis = c;
        }
    }
    cout<<dis<<"\n";
    return 0;
}

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

int main(){

	int n, m;
	long long sum = 0;
	
	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> m;
		sum += m;
	}
	int result = floor((double)sum / n);
	cout << result << endl;

	return 0;

}

Measured memory_bytes: 1160
from math import cos, pi

value = input().split()
A = int(value[0])
B = int(value[1])
H = int(value[2])
M = int(value[3])

if 0 < A < 1001 and 0 < B < 1001 and 0 <= H <=11 and 0 <= M <= 59:
    print(pow(float(A)**2 + float(B)**2 - 2*float(A)*float(B)*cos(pi*abs(float(H)*30 - float(M)*6 + 0.5*float(M))/180),0.5))
else:
    print("Choose value in interval define on the exercise")

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

int k;
string S;
int ans;

void in();
void solve();
void out();
int backtrack(int i, int K, bool b);
int Ch(int a, int b);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> S >> k;
}

void solve(){
    ans = backtrack(0, k, 1);
}

int backtrack(int i, int K, bool b){
    if(K == 0)
        return 1;
    if(i == S.size())
        return 0;
    if(!b){
        int wow = S.size() - i;
        return Ch(wow, K) * pow(9, K);
    }
    int ans = 0;
    if(S[i] == '0')
        ans += backtrack(i + 1, K, b);
    else
        ans += backtrack(i + 1, K, 0) + backtrack(i + 1, K - 1, b) + (S[i] - '0' - 1) * backtrack(i + 1, K - 1, 0);
    return ans;
}

int Ch(int a, int b){
    if(b > a)
        return 0;
    int ans = 1;
    for(int i = 0; i < b; i++)
        ans *= a - i;
    for(int i = 0; i < b; i++)
        ans /= i + 1;
    return ans;
}

void out(){
    cout << ans;
}



Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;

void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}


int main() {
	int N, M, X, Y; cin >> N >> M >> X >> Y;
	VI x(N), y(M);
	REP(i, N) cin >> x[i];
	REP(i, M) cin >> y[i];
	int xx = *max_element(ALL(x));
	int yy = *min_element(ALL(y));
	bool flg = false;
	for (int Z = X + 1; Z <= Y; ++Z) if (xx < Z && Z <= yy) flg = true;
	cout << ((!flg) ? "War" : "No War");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=200000;
map<int,int> buc;
int n,k;
int a[maxn+5];
int Sub(int x,int y)
{
	x-=y;
	if(x<0) x+=k;
	return x;
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) a[i]=(a[i-1]+a[i])%k;
	buc[Sub(a[0],0)]++;
	int now=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		while(now<i-k+1) buc[Sub(a[now],now%k)]--,now++;
		ans+=buc[Sub(a[i],i%k)];
		buc[Sub(a[i],i%k)]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

saisyo = float("inf")
for i in range(2**N):
    a = [0]*M
    gokei = 0
    for j in range(N):
        if (i>>j)&1:
            gokei += A[j][0]
            for k in range(1, M+1):
                a[k-1] += A[j][k]
    if all(a[l] >= X for l in range(M)):
        saisyo = min(saisyo, gokei)

print(saisyo if saisyo != float("inf") else -1)

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

struct point{
    double x,y;
};

void koch(int n,point a,point b){
    if(n==0) return;
    point s,t,u;
    double th = (M_PI*60.0)/180.0;
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    cout<<setprecision(10)<<s.x<<" "<<setprecision(10)<<s.y<<endl;
    koch(n-1,s,u);
    cout<<setprecision(10)<<u.x<<" "<<setprecision(10)<<u.y<<endl;
    koch(n-1,u,t);
    cout<<setprecision(10)<<t.x<<" "<<setprecision(10)<<t.y<<endl;
    koch(n-1,t,b);
}

int main(){

    
    int N;
    cin>>N;
    point a,b;
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    cout<<a.x<<" "<<a.y<<" "<<endl;
    koch(N,a,b);
    cout<<b.x<<" "<<b.y<<" "<<endl;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      long int a;
      long int b;
      cin>>a>>b;
      if(a==b)
      {
        for(int i=0;i<a;i++)
        {
          cout<<a;
        }
      }
      else
      {
        long int m=min(a,b);
        long int mx=max(a,b);
        for(int i=0;i<mx;i++)
        {
          cout<<m;
        }
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    string s;
    cin >> s;
    ll gc=0,pc=0,ans=0;
    for (ll i=0;i<s.size();i++){
        if (s[i]=='p'){
            if (gc>pc){
                pc++;
            }else{
                ans--;
                gc++;
            }
        }else{
            if (gc>pc){
                pc++;
                ans++;
            }else{
                gc++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, W;
    cin >> N >> W;

    int V = 100100;
    long long inf = 100000000010000;
    long long dp[N + 1][V];
    for (int i = 0; i < V; ++i) {
        dp[0][i] = inf;
    }
    
    dp[0][0] = 0;
    int w, v;
    for (int n = 1; n < N + 1; ++n) {
        cin >> w >> v;
        for (int i = 0; i < V; ++i) {
            if (i - v >= 0) {
                dp[n][i] = min(dp[n - 1][i - v] + w, dp[n - 1][i]);
            } else {
                dp[n][i] = min(dp[n - 1][0] + w, dp[n - 1][i]);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < V; ++i) {
        if (dp[N][i] <= W) {
            res = max(res, i);
        } else {
            break;
        }
    }    
    
    cout << res << endl;
}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = a + a + b + b;

		System.out.println(area + " " + length);

	}
}

Measured memory_bytes: 26168
a = list(input())
op = ['-'] * 3
for i in range(2**3):
    ans = int(a[0])
    for j in range(3):
        if 1 & (i>>j):
            ans += int(a[3-j])
            op[2-j] = '+'
        else:
            ans -= int(a[3-j])
            op[2-j] = '-'
    if ans == 7:
        break
print(a[0] + op[0] + a[1] + op[1] + a[2] + op[2] +a[3] + "=7")


Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	int minuit = 60 * H + M;
	double theta = min(abs(minuit * 0.5 - M * 6), 360 - abs(minuit * 0.5 - M * 6)) / 180 * M_PI;
	printf("%.9lf\n", sqrt(A * A + B * B - 2 * A * B * cos(theta)));
	return 0;
}

Measured memory_bytes: 4192
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int Mod=998244353;
const int N=400000;
int n;
#define Maxn 400010
char str[Maxn];
int ch[Maxn];
int F[Maxn],two[Maxn];
vector<int> vec[Maxn];

int head[Maxn],v[Maxn<<1],nxt[Maxn<<1],w[Maxn<<1],tot=0;
int col[Maxn],bel[Maxn],cnt;
vector<int> seq[Maxn];
inline void add_edge(int s,int e,int t){
	tot++;v[tot]=e;w[tot]=t;nxt[tot]=head[s];head[s]=tot;
}

bool flag=true;
void dfs(int u,int c){
	col[u]=c;
	bel[u]=cnt;
	seq[cnt].push_back(u);
    for(int i=head[u];i;i=nxt[i])
        if(col[v[i]]==-1)
        	dfs(v[i],(c+w[i])&1);
        else if((col[u]^col[v[i]])!=w[i])flag=false;
}
bool vis[Maxn];
char num[Maxn];
inline int solve(int x){
	cnt=0;
	tot=0;memset(head,0,sizeof(int)*(n+1));
	flag=true;
	for(register int i=1;i<=n;++i){
		int to=(i-x+n)%n;
		if(to==0)add_edge(i,n,0);
		else add_edge(i,to,0);
	}
	for(register int i=1;i<=n/2;++i){
		add_edge(i,i+n/2,1);
		add_edge(i+n/2,i,1);
	}
	memset(col,-1,sizeof(int)*(n+1));
	for(register int i=1;i<=n;++i)
	    if(col[i]==-1){
	    	cnt++;
	    	seq[cnt].clear();
	    	dfs(i,0);
	    	if(!flag)return 0;
		}
	memset(vis,false,sizeof(bool)*(n+1));
	int tmp=0,res=0;
	bool z=false;
    for(register int i=1;i<=n;++i)
        if(!vis[i]){
        	if(ch[i]==1)res=(res+two[cnt-tmp-1])%Mod;
        	int t=bel[i];
        	for(int j=0;j<seq[t].size();++j){
        		vis[seq[t][j]]=true;
        		num[seq[t][j]]=(ch[i]^col[seq[t][j]]);
			}
			tmp++;
		}else{
			if(num[i]>ch[i])break;
			if(num[i]<ch[i]){
				res=(res+two[cnt-tmp]);
				break;
			}
			if(i==n)z=true;
		}
	if(z)res++;
	return res;
}

int main(){
	two[0]=1;
	for(register int i=1;i<=N;++i)two[i]=(two[i-1]+two[i-1])%Mod;
	for(register int i=1;i<=N;++i)
	    for(register int j=i;j<=N;j+=i)
	        vec[j].push_back(i);
    scanf("%d",&n);
    scanf("%s",str+1);
    for(register int i=1;i<=n;++i)ch[i]=str[i]-'0';
    for(register int i=n+1;i<=2*n;++i)ch[i]=1;
    int ans=0;
    n<<=1;
    for(register int i=0;i<vec[n].size();++i){
    	if(n/vec[n][i]%2!=0)F[i]=solve(vec[n][i]);
    	else F[i]=0;
    	for(register int j=0;j<i;++j)
    	    if(vec[n][i]%vec[n][j]==0)F[i]=(F[i]-F[j]+Mod)%Mod;
	    ans=(ans+1ll*vec[n][i]*F[i])%Mod;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 115824
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  u64 az[26];
  for (int i = 0; i < 26; ++i) az[i] = 0;
  cin >> s;
  u64 slen = s.size();
  for (u64 i = 0; i < slen; ++i) {
    int idx = s[i]-'a';
    if (idx < 0 || 26 <= idx) {
      return 1;
    }
    az[idx]++;
  }
  u64 ans = 1;
  for (int i = 0; i < 26; ++i) {
    for (int j = i+1; j < 26; ++j) {
      ans += az[i] * az[j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int N, M;
double lim = 1.0 / 1000000000.0;


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

    double ans = 0;

    double prb = 1.0 / pow(2.0, (double)M);
    double t = 100 * (N - M) + 1900 * M;

    int i = 1;
    double prb2 = 1.0;
    while(lim < i * t * prb * prb2){
        ans += i * t * prb * prb2;
        prb2 *= 1.0 - prb;
        i++;
    }

    cout << ans << endl;
}

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

using namespace std;

#define fi first
#define se second

const int maxn = 1e5 + 5;

pair<pair<int, int>, int> a[maxn];
int n;
set<int> has;

int main() {
    // freopen("inp.txt", "r", stdin);

    cin >> n;

    for (int i = 0; i < 2 * n; i++) {
        cin >> a[i].fi.fi >> a[i].fi.se;
        a[i].se = i;
    }

    sort(a, a + 2 * n);

    int ans = 0;
    for (int i = 0; i < 2 * n; i++) {
        if (a[i].se < n) {
            has.insert(a[i].fi.se);
        }
        else {
            set<int>::iterator it = has.upper_bound(a[i].fi.se);
            if (it == has.begin()) continue;
            it--;
            int cur = *it;
            ans++;
            has.erase(cur);
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  if (s.size() == 2) {
    if (s[0] == s[1]) cout << "1 2" << endl;
    else cout << "-1 -1" << endl;
    return 0;
  }
  for (int i = 0; i + 3 <= s.size(); i++) {
    string t = s.substr(i, 3);
    map<char, int> mp;
    for (int j = 0; j < 3; j++) {
      mp[t[j]]++;
    }
    if (mp.size() <= 2) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;

  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string s[100010];
std::map<std::string, ll> cnt;

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

  rep( i, N ) {
    std::cin >> s[i];

    std::sort( all(s[i]) );
    ++cnt[s[i]];
  }

  ll ans = 0;

  itr( it, cnt ) if( it->second >= 2 ) {
    ans += it->second*(it->second-1)/2;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 14420
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S;

    REP(i, H) {
        string si;
        cin >> si;
        S.push_back(si);
    }

    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '.') {
                int count = 0;
                for (int h = i - 1; h <= i + 1; h++) {
                    for (int w = j - 1; w <= j + 1; w++) {
                        if (h >= 0 && h < H && w >= 0 && w < W && S[h][w] == '#')
                            count++;
                    }
                }
                S[i][j] = '0' + count;
            }
        }
    }

    REP(i, H)
        cout << S[i] << endl;

    return 0;
}


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

// 内部定数
#define D_H_MAX			35										// 最大高さ

// 内部変数
static FILE *szpFpI;											// 入力
static int siN;													// N

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 祖先 - 取得
int
fGetP(
	int piVal					// <I> 値
	, int *pipP					// <O> 祖先
	, int *pipPCnt				// <O> 祖先数
)
{
	// 初期値
	pipP[0] = piVal;
	*pipPCnt = 1;

	// 祖先
	while (piVal > 1) {
		piVal = (piVal + siN - 2) / siN;
		pipP[*pipPCnt] = piVal;
		(*pipPCnt)++;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// N, クエリ数 - 取得
	int liQCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siN, &liQCnt);

	// クエリ - 取得
	for (i = 0; i < liQCnt; i++) {
		int liVal1, liVal2;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &liVal1, &liVal2);

		// N=1
		if (siN == 1) {
			if (liVal1 < liVal2) {
				sprintf(lc1Buf, "%d\n", liVal1);
			}
			else {
				sprintf(lc1Buf, "%d\n", liVal2);
			}
		}

		// N>1
		else {

			// 祖先 - 取得
			int li1P1[D_H_MAX], liP1Cnt, li1P2[D_H_MAX], liP2Cnt;
			fGetP(liVal1, li1P1, &liP1Cnt);
			fGetP(liVal2, li1P2, &liP2Cnt);

			// 開始番号
			int liSNo1 = 0;
			int liSNo2 = 0;
			if (liP1Cnt < liP2Cnt) {
				liSNo2 = liP2Cnt - liP1Cnt;
			}
			else {
				liSNo1 = liP1Cnt - liP2Cnt;
			}

			// 共通祖先 - 取得
			while (li1P1[liSNo1] != li1P2[liSNo2]) {
				liSNo1++;
				liSNo2++;
			}
			sprintf(lc1Buf, "%d\n", li1P1[liSNo1]);
		}

		// 出力
		fOutLine(lc1Buf);
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
int main(void)
{
  std::string s;
  int k, l;
  std::cin >> s >> k;
  std::set<std::string> substring;
  l = s.size();
  for (int i = 0; i < l; i++){
    for (int j = 1; j <= k && i + j <= l; j++){
      substring.insert(s.substr(i, j));
    }
  }
  auto itr = substring.begin();
  for (int i = 1; i != k; i++) itr++;
  std::cout << *itr << std::endl;
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

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

const double INF = 1e13;

int N;
double x[1002];
double y[1002];
double r[1002];
double dist[1002][1002];

double d(int i,int j){
	return max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-(r[i] + r[j]));
}

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

	int xs,ys,xt,yt;
	cin >> xs >> ys >> xt >> yt;
	cin >> N;

	x[0] = 1.0 * xs;
	y[0] = 1.0 * ys;
	r[0] = 0.0;
	x[N+1] = 1.0 * xt;
	y[N+1] = 1.0 * yt;
	r[N+1] = 0.0;

	rep(i,N){
		int xx,yy,rr;
		cin >> xx >> yy >> rr;
		x[i+1] = 1.0 * xx;
		y[i+1] = 1.0 * yy;
		r[i+1] = 1.0 * rr;
	}

	rep(i,N+2){
		rep(j,N+2){
			dist[i][j] = i == j ? 0.0 : d(i,j);
		}
	}

	// dijkstra
	double g[N+2];
	fill(g,g+N+2,INF);
	g[0] = 0;

	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(dist[0][0],0));

	while(!q.empty()){
		P p = q.top();
		q.pop();

		if(p.first > g[p.second]) continue;
		rep(i,N+2){
			if(i == p.second) continue;
			if(g[i] > p.first + dist[p.second][i]){
				g[i] =  p.first + dist[p.second][i];
				q.push(P(g[i],i));
			}
		}
	}

	cout << setprecision (10) << g[N+1] << endl;
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
int main(){
  char C11,C12,C13,C21,C22,C23;
  cin >> C11 >> C12 >> C13 >> C21 >> C22 >> C23;
  if (C11==C23 && C12==C22 && C13==C21){
    cout << "YES";
  } else {
    cout << "NO";
  }
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; s[i] != '\0' && s[i] != '\n'; i++){
        if(s[i] + n > 'Z'){
            s[i] = 'A' + (s[i] + n - 'Z') - 1;
        }else{
            s[i] = s[i] + n;
        }
    }
    cout << s << endl;
}

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

int main() {
    int n, k; cin >> n >> k;
    int l[n]; for (int i = 0; i < n; i++) cin >> l[i];
    sort(l, l + n, greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++) ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
 
n,m = list(map(int, input().split()))

dan=[]

for i in range(m):
    b=list(map(int, input().split()))
    dan.append(b[0])

fib=[0 for i in range(n+2)]
fib[1]=1
fib[2]=2

for ii in range(n-1):
    i=ii+3
    fib[i]=(fib[i-1]+fib[i-2])%1000000007
    
#print(fib,dan)

eachans=[]

if(m==0):
    print(fib[n])

if(m>=1):
    if(dan[0]!=1):
        eachans.append(fib[dan[0]-1])

    for i in range(m-1):
        if(dan[i+1]-dan[i]-2 == 0):
            eachans.append(1)
        elif(dan[i+1]-dan[i]-2 == -1):
            eachans.append(0)
        else:
            eachans.append(fib[dan[i+1]-dan[i]-2])
        #print(dan[i+1]-dan[i]-1)

if(m>=1):
    if(dan[-1]!=n-1):
        eachans.append(fib[n-dan[-1]-1])
    
if(m>=1):
    #print(eachans)
    ans=1
    for i in range(len(eachans)):
        ans = ans*eachans[i]%1000000007

    print(ans)

Measured memory_bytes: 11928
a,b,c,x,y=map(int,input().split())
z=min(x,y)
z_max=max(x,y)
cost=0

if a+b > 2*c:
	cost=min(2*c*z+a*(x-z)+b*(y-z),
	         2*c*z_max)
else:
	cost=a*x + b*y

print(cost)

Measured memory_bytes: 3060
#include<iostream>
 
using namespace std;
int main(){
	int a,b,c;
  cin>>a>>b>>c;
  	if((c-(a-b))>=0)
  	cout<<c-(a-b);
  	else 
      cout<<0;
 
 
 
 
 
 
 
 
return 0;
}

Measured memory_bytes: 256
<?php
    while(true) {
        $card = trim(fgets(STDIN));
        if($card == "-") exit;

        $count = trim(fgets(STDIN));

        for($i = 0; $i < $count; $i++){
            $change = trim(fgets(STDIN));
            $card = substr($card, $change).substr($card, 0, $change);
        }

        echo $card."\n";            
    }
   

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

int main() {
  int n;
  cin >> n;
  
  string m = "7";
  for(int i=0; i<7; i++) {
    if(stoi(m)>=n) break;
    m += "7";
  }
  
  bool rr = false;
  int ans = m.size();
  for(int i=0; i<=1000000; i++) {
    if(stoi(m)%n==0) break;
    m = to_string(stoi(m)%n)+"7";
    ans++;
    if(i==1000000) rr = true;
  }
  if(rr) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

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

int main() {
	// your code goes here
	int n,k;
	string s;
	cin >> n >> k;
	k--;
	cin >> s;
	for(int i = 0 ; i < n ; i++)
	{
		if(i == k)
		s[i] = tolower(s[i]);
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007


int32_t main(){
    IOS;

int n,W;
cin>>n>>W;

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

for(int i=0;i<n;i++)
{
    int w,v;
    cin>>w>>v;
    
    for(int j = W-w;j>=0;j--)
    {
        dp[j+w] = max(dp[j+w] , dp[j] + v);
    }

}

cout<<dp[W]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10;
struct zz{
	int a,b;
}p[N];
int n,sum;
int cmp(zz x,zz y){
	return x.a>y.a;
}
signed main(){
	scanf("%lld",&n); 
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&p[i].a,&p[i].b);
		sum+=p[i].a;
		p[i].a=max(p[i].a,p[i].b);
	}
	sort(p+1,p+n+1,cmp);
	int k=0,ss=0;
	for (int i=1;i<=n;i++){
		ss+=p[i].a;
		if (ss>=sum){
			k=i;
			break;
		}
	}
	int P=1,Q=1;
	for (int i=1;i<=n;i++){
		int now=sum-(ss-p[min(i,k)].a);
		if (now<=p[i].b&&now*Q<P*p[i].b)P=now,Q=p[i].b;
	}
	P=Q-P+(n-k)*Q,Q*=n;
	int g=__gcd(P,Q);P/=g,Q/=g;
	printf("%lld %lld\n",P,Q);
	return 0;
}

Measured memory_bytes: 1792
import math
ryouri = [int(input()) for i in range(5)]

order_1 = [(i-1)*0.1 - int((i-1)*0.1) for i in ryouri]
min_v = 999
min_id = 0
for i, v in enumerate(order_1):
    if v < min_v:
        min_v = v
        min_id = i

goukei = 0
for i, (price, order) in enumerate(zip(ryouri, order_1)):
    if i == min_id:
        goukei = goukei + price
    else:
        goukei = goukei + math.ceil(price*0.1)*10

print(goukei)


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

long long int countRepeated( long long int a, long long int b, long long int c )
{
    long long int cnt = 1;
    c = c * a % b;
    while( c != 1 )
    {
        cnt++;
        c = c * a % b;
    }
    return cnt;
}

long long int GCD( long long int a, long long int b )
{
    return a % b == 0 ? b : GCD( b, a % b );
}

long long int LCM( long long int a, long long int b )
{
    return a * b / GCD( a, b );
}

int main()
{
    long long int a[6];
    while(1)
    {
        long long int sum = 0;
        for( long long int i = 0; i < 6; i++ )
        {
            cin >> a[i];
            sum += a[i];
        }

        if( !sum )
            break;

        long long int x = countRepeated( a[0], a[1], 1 );
        long long int y = countRepeated( a[2], a[3], 1 );
        long long int z = countRepeated( a[4], a[5], 1 );        

        cout << LCM( LCM( x, y ), z ) << endl;
    }

    return 0;
}


Measured memory_bytes: 3004
S = input()
s_rev = S[::-1]

r_list = [0] * 2019
r_list[0] = 1
num, d = 0, 1
for i in range(len(S)):
    num += d*int(s_rev[i])
    num %= 2019
    r_list[num] += 1
    d *= 10
    d %= 2019

ans = 0
for i in range(2019):
        ans += r_list[i]*(r_list[i]-1)//2

print(ans)


Measured memory_bytes: 9252
from collections import defaultdict
def main():
    n, m = map(int, raw_input().split())
    a = map(int, raw_input().split())
    b = map(int, raw_input().split())
    s = defaultdict(list)
    t = defaultdict(list)
    for i, x in enumerate(a):
        s[x].append(i)
    for i, x in enumerate(b):
        t[x].append(i)
    N = n * m
    w = 0
    ans = 1
    u = [[1] * m for _ in xrange(n)]
    for i in xrange(N, 0, -1):
        if len(s[i]) > 1 or len(t[i]) > 1:
            print 0
            return
        if len(s[i]) == 1 and len(t[i]) == 1:
            x = s[i][0]
            y = t[i][0]
            for j in xrange(m):
                if b[j] > i:
                    w += u[x][j]
                    u[x][j] = 0
            for j in xrange(n):
                if a[j] > i:
                    w += u[j][y]
                    u[j][y] = 0
        elif len(s[i]) == 1:
            x = s[i][0]
            c = 0
            for j in xrange(m):
                if b[j] > i:
                    c += 1
                    w += u[x][j]
                    u[x][j] = 0
            w -= 1
            ans = ans * c % 1000000007
        elif len(t[i]) == 1:
            y = t[i][0]
            c = 0
            for j in xrange(n):
                if a[j] > i:
                    c += 1
                    w += u[j][y]
                    u[j][y] = 0
            w -= 1
            ans = ans * c % 1000000007
        else:
            if w <= 0:
                print 0
                return
            ans = ans * w % 1000000007
            w -= 1
    print ans
main()


Measured memory_bytes: 276040
#include<cstdio>
#include<iostream>
#include<cstring>

const int MAXN=1e5;
int ans=-0x3f3f3f3f,tmp=0;
char c[MAXN];

using namespace std;
int main()
{
	scanf("%s",c+1);
	int lenth=strlen(c+1);
	for (int i=1;i<=lenth;i++)
	{
		if (c[i]=='R')
		{
			tmp++;
			ans=max(ans,tmp);
		} 
		else
		{
			tmp=0;
			ans=max(ans,tmp);
		}
	}
	printf("%d",ans);
}

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

int dp[5005][5005];

int main() {
    int n;
    string s;
    cin>>n>>s;
    for(int i=n-1;i>=0;--i) {
        for(int j=n-1;j>=0;--j) {
            if(s[i]!=s[j])  dp[i][j]=0;
            else    dp[i][j]=dp[i+1][j+1]+1;
        }
    }
    int ans=0;
    rep(i,n)rep(j,n) {
        if(i>=j)    continue;
        int now=min(dp[i][j],j-i);
        ans=max(ans,now);
    }
    cout<<ans<<endl;
  
 return 0;
}

Measured memory_bytes: 98048
#include<bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

const int N=200005,M=262205,P=(441<<21)+1,g=5,K=10000005;

int memory[K],*pointer=memory;
inline int lset(int n){int l=1;while(l<n)l<<=1;return l;}
inline int *getarr(int l){int*ret=pointer;pointer+=l;return ret;}

int *sum[M<<1],*mul[M<<1],_w[20][M];
int n,sz[N],cnt[N];
vector<int>e[N];

inline int fpow(int a,int t){
	static int r;
	for(r=1;t;a=(ll)a*a%P,t>>=1)if(t&1)r=(ll)r*a%P;
	return r;
}

void predo(int n){
	n++;n=lset(n);
	int l=2,p=1,w;
	while(l<=n){
		w=fpow(g,(P-1)/l);
		int*f=_w[p];f[0]=1;
		for(int j=1;j<(l>>1);j++)f[j]=(ll)f[j-1]*w%P;
		l<<=1,p++;
	}
}

void ntt(int*a,int n,int d){
	int i,j=n>>1,k,t=0,l,u,v,*p;
	for(i=1;i<n-1;i++){
		if(i<j)swap(a[i],a[j]);
		for(k=n>>1;(j^=k)<k;k>>=1);
	}
	for(l=2;l<=n;l<<=1){
		i=l>>1,p=_w[++t];
		for(j=0;j<n;j+=l)for(k=0;k<i;k++){
			u=a[j+k],v=(ll)a[j+k+i]*p[k]%P;
			a[j+k]=(u+v)%P,a[j+k+i]=(u-v+P)%P;
		}
	}
	if(d==-1){
		for(i=0,v=fpow(n,P-2);i<n;i++)a[i]=(ll)a[i]*v%P;
		for(i=1;i<n/2;i++)swap(a[i],a[n-i]);
	}
}

void conv(int*a,int na,int*b,int nb,int*r,int n){
	static int ta[M],tb[M],tc[M];
	na++,nb++,n++;int m=lset(n);
	memset(ta,0,m<<2),memset(tb,0,m<<2),memcpy(ta,a,na<<2),memcpy(tb,b,nb<<2);
	ntt(ta,m,1),ntt(tb,m,1);
	for(int i=0;i<m;i++)tc[i]=(ll)ta[i]*tb[i]%P;
	ntt(tc,m,-1);
	memcpy(r,tc,n<<2);
}

void check(int x,int l,int r){
	if(l==r){
		sum[x]=getarr(2),mul[x]=getarr(2);
		sum[x][0]=sum[x][1]=cnt[l],mul[x][0]=mul[x][1]=1;
		return;
	}
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1,dl=mid-l+1,dr=r-mid,dn=r-l+1;
	check(ls,l,mid),check(rs,mid+1,r);
	sum[x]=getarr(dn+1),mul[x]=getarr(dn+1);
	conv(mul[ls],dl,mul[rs],dr,mul[x],dn);
	conv(mul[ls],dl,sum[rs],dr,sum[x],dn);
	for(int i=0;i<=dl;i++)(sum[x][i]+=sum[ls][i])%=P;
}

void dfs(int x,int fa){sz[x]=1;for(int v:e[x])if(v!=fa)dfs(v,x),sz[x]+=sz[v];}

int main(){
	scanf("%d",&n);
	predo(n);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),e[u].pb(v),e[v].pb(u);
	dfs(1,0);
	for(int i=2;i<=n;i++)cnt[sz[i]]--,cnt[n-sz[i]]--;
	cnt[n]+=n;
	for(int i=1;i<=n;i++)if(cnt[i]<0)cnt[i]+=P;
	check(1,1,n);
	for(int k=1;k<=n;k++)printf("%d\n",sum[1][k]);
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define rep(i, n) for(LL i = 0;i < n;i++)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int T

/*************** using variables ***************/

/**********************************************/

template<typename T>
struct Edge {
  int to;
  T cap;
  int rev;
};

template<typename T>
class Dinic {
 private:
  int V;  // 頂点数
  vector<T> minCost;
  vector<int> iter;
  vector<vector<Edge<T>>> graph;
  const T INF = numeric_limits<T>::max();
  bool Bfs(int s, int t);
  T Dfs(int idx, const int t, T flow);

 public:
  explicit Dinic(int n);
  void AddEdge(int from, int to, T cap);
  T Run(int s, int t);
};

template<typename T>
Dinic<T>::Dinic(int n) : V(n) { graph.assign(V, vector<Edge<T>>()); }

template<typename T>
void Dinic<T>::AddEdge(int from, int to, T cap) {
  graph[from].push_back((Edge<T>){to, cap, static_cast<int>(graph[to].size())});
  graph[to].push_back((Edge<T>){from, 0, static_cast<int>(graph[from].size() - 1)});
}

template<typename T>
bool Dinic<T>::Bfs(int s, int t) {
  minCost.assign(graph.size(), -1);
  queue<int> que;
  minCost[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    for (auto &e : graph[p]) {
      if (e.cap > 0 && minCost[e.to] < 0) {
        minCost[e.to] = minCost[p] + 1;
        que.push(e.to);
      }
    }
  }
  return (minCost[t] != -1);
}

template<typename T>
T Dinic<T>::Dfs(int idx, const int t, T flow) {
  if (idx == t) return flow;
  for (int &i = iter[idx]; i < static_cast<int>(graph[idx].size()); ++i) {
    Edge<T> &e = graph[idx][i];
    if (e.cap > 0 && minCost[idx] < minCost[e.to]) {
      T d = Dfs(e.to, t, min(flow, e.cap));
      if (d > 0) {
        e.cap -= d;
        graph[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

template<typename T>
T Dinic<T>::Run(int s, int t) {
  T flow = 0;
  while (Bfs(s, t)) {
    iter.assign(graph.size(), 0);
    T f = 0;
    while ((f = Dfs(s, t, INF)) > 0) {
      flow += f;
    }
  }
  return flow;
}
signed main(){
    int n;
    vector<P> blue, red;

    cin >> n;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        red.pb(P(a, b));
    }
    rep(i, n){
        int c, d;
        cin >> c >> d;
        blue.pb(P(c, d));
    }

    Dinic<LL> f(n*2 + 2);
    rep(i, n){
        f.AddEdge(0, i+1, 1);
        f.AddEdge(n+1+i, n*2+1, 1);
    }
    rep(i, n){
        rep(j, n){
            if(red[i].first < blue[j].first && red[i].second < blue[j].second){
                f.AddEdge(i+1, j+n+1, 1);
            }
        }
    }

    cout << f.Run(0, n*2+1) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    map<int,int> m;
    rep(i,n) {
        int num; cin >> num;
        m[num]++;
    }
    if((int)m.size()%2==0) cout << (int)m.size()-1 << endl;
    else cout << (int)m.size() << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vi b;
    b.resize(N);

    int num = 0;
    vi c;
    c.resize(N + 1);
    c[0] = 0;
    vi d;
    d.resize(N + 1);
    d[0] = 0;
    REP(i, N)
    {
        if (S[i] == '.')
        {
            b[i] = false;
            c[i + 1] = c[i] + 1;
            d[i + 1] = d[i];
        }
        else
        {
            b[i] = true;
            num++;
            c[i + 1] = c[i];
            d[i + 1] = d[i] + 1;
        }
    }
    int ans = INF;
    int tmp;
    REP(i, N + 1)
    {
        tmp = d[i] + c[N] - c[i];
        chmin(ans, tmp);
    }

    cout << ans << endl;

    // system("pause");
}

Measured memory_bytes: 5252
s = gets.chomp.split("")


def switch_tile(n)
    n == 0 ? 1 : 0
end

def diff_cnt(left_array, right_array)
    raise RuntimeError.new("size not match #{left_array}:#{right_array}") unless left_array.size == right_array.size
    res = 0
    left_array.each_with_index do |i, idx|
        res += 1 if left_array[idx] != right_array[idx]
    end
    return res
end

def generate_tiles(l, first_zero = true)
    current = 1
    current = 0 if first_zero
    res = ""
    l.times do 
        res += current.to_s
        current = switch_tile(current)
    end
    return res
end

cand_a = generate_tiles(s.size, false).split("")
cand_b = generate_tiles(s.size, true).split("")

diff_a = diff_cnt(cand_a, s)
diff_b = diff_cnt(cand_b, s)

puts [diff_a, diff_b].min


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

#define int long long

const int N = 3e6 + 9;

long long ar[N],br[N],cr[N],dr[N],er[N],x,y,z,k,pos=0,val=0;

using namespace std;

signed main()

{
	cin >> x >> y >> z >> k;
	for (int i=0;i<x;i++) cin >> ar[i];
	for (int i=0;i<y;i++) cin >> br[i];
	for (int i=0;i<z;i++) cin >> cr[i];
	for (int i=0;i<x;i++){
		for (int j=0;j<y;j++){
			dr[pos++] = ar[i] + br[j];
		}
	}
	sort(dr, dr + pos);
	reverse(dr, dr + pos);
	sort(cr, cr + z);
	reverse(cr, cr + z);
	for (int i=0;i<z;i++){
		for (int j=0;j<k;j++){
			er[val++] = dr[j] + cr[i];
		}
	}
	sort(er, er + val);
	reverse(er, er + val);
	for (int i=0;i<k;i++) cout << er[i] << "\n";
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

using namespace std;

const int limit = 200010;

int in[limit];
bool visited[limit];
int grundy[limit];
vector<int> graph[limit],rgraph[limit];
int cycle[limit];

bool check(int n){
	rep(v,n){
		set<int> s;
		for(auto &v2:graph[v]) s.insert(grundy[v2]);
		rep(i,grundy[v]) if(s.find(i)==end(s)) return false;
		if(s.find(grundy[v])!=end(s)) return false;
	}
	return true;
}

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

	vector<int> p(n);
	rep(i,n){
		cin >> p[i],p[i]--;
		graph[p[i]].push_back(i);
		rgraph[i].push_back(p[i]);
		in[p[i]]++;
	}

	queue<int> q;
	rep(i,n){
		grundy[i]=-1;
		cycle[i]=true;
		if(in[i]==0) q.push(i);
	}

	while(!q.empty()){
		int v = q.front(); q.pop();
		cycle[v]=false;
		set<int> s;
		for(auto &v2:graph[v]) s.insert(grundy[v2]);
		grundy[v]=0;
		while(s.find(grundy[v])!=end(s)) grundy[v]++;
		for(auto &v2:rgraph[v]) if(--in[v2]==0) q.push(v2);
	}
	
	int cmin = -1;
	rep(v,n) if(cycle[v]) cmin = v;
	bool ok = true;

	if(cmin!=-1){
		vector<int> cand;
	
		{
			set<int> s;
			for(auto &v2:graph[cmin]) s.insert(grundy[v2]);
			int cur = 0;
			while(cand.size()<2){
				while(s.find(cur)!=end(s)) cur++;
				cand.push_back(cur++);
			}
		}

		
		ok = false;
		for(auto &elem:cand){
			rep(v,n) if(cycle[v]) grundy[v]=-1;
			grundy[cmin]=elem;

			for(auto &v2:rgraph[cmin]) if(grundy[v2]==-1) q.push(v2);

			while(!q.empty()){
				int v = q.front(); q.pop();
				//cerr << elem << " " << cmin << " " << v << endl;
				set<int> s;
				for(auto &v2:graph[v]) s.insert(grundy[v2]);
				grundy[v]=0;
				while(s.find(grundy[v])!=end(s)) grundy[v]++;
				//cerr << grundy[v] << endl;
				for(auto &v2:rgraph[v]) if(grundy[v2]==-1) q.push(v2);
			}

			if(check(n)) ok=true;
		}	
	}

	
	if(ok)
		puts("POSSIBLE");
	else
		puts("IMPOSSIBLE");


	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;

int num[222222];

signed main(){
    cin>>N>>K;
    for(int i=1;i<=N;i++)num[i%K]++;
    int ans=0;
    rep(i,K){
        if((2*i)%K!=0)continue;
        ans+=num[i]*num[(K-i)%K]*num[(K-i)%K];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AIZU {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			int[] I = cins();
			int r = I[0] + I[1];
			print(r>=10?"error":r.ToString());
		}
		
	}
}

Measured memory_bytes: 11220