akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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 T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

constexpr int N=1e5+10;
constexpr ll INF=1e9+7;
ll a[N*16];
ll sum[11];
main(){
    int h,w,n;cin>>h>>w>>n;
    int x,y;
    int cnt=0;
    ll m=(ll)(h-2)*(w-2);
    rep(iii,n){
        cin>>x>>y;
        rep(i,3)rep(j,3)if( x-i>=1 && x-i<=h-2 && y-j>=1 && y-j<=w-2){
            a[cnt++]=INF*(x-i)+(y-j);
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<endl;
    rep2(i,1,9)cout<<sum[i]<<endl;
}



Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s,t;
    cin >> s >> t;
    string copy = s;
    for(int i = 0;i < s.size()+10; i++){
        if(copy == t){
            cout <<"Yes"<<endl;
            return 0;
        }else{
            string copy2 = copy.substr(copy.size()-1);
            copy.erase(copy.size()-1);
            copy2 += copy;
            copy = copy2;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n;
int answer = 100000;
int i;
int a,b;

int main(void)
{
    scanf("%d",&n);

    for(i = 0;i < n;i++)
    {
        answer = answer * 1.05;
    a = answer % 1000;
    if(a != 0)
    {
        answer = answer - a + 1000;
    }
    }

    printf("%d\n",answer);
    return 0;
}

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

int main() {
  int r,D,x2000;
  cin >> r >> D >> x2000;
  
  vector<int> x(10);
  	x.at(0)= r * x2000 - D ;
  	cout << x.at(0) << endl;
  	for ( int i = 1 ; i < 10 ; i++ ){
    	x.at(i) = r * x.at(i-1) - D ;
      	cout << x.at(i) << endl;;
    }
}

Measured memory_bytes: 256
use std::io::{self, Read};

macro_rules! input {
    ($it: expr) => ($it.next().unwrap().parse().unwrap());
    ($it: expr, $T: ty) => ($it.next().unwrap().parse::<$T>().unwrap());
}

fn main() {
    let mut buf = String::new();
    let mut it = {
        io::stdin().read_to_string(&mut buf).unwrap();
        buf.split_whitespace()
    };

    let n: usize = input!(it);
    let k: usize = input!(it);
    let a: Vec<usize> = (0..n).map({ |_| input!(it, usize) - 1 }).collect();

    let mut ans: usize = 0;
    let mut x: Vec<usize> = a;
    for i in 0..60 {
        if k & (1 << i) != 0 {
            ans = x[ans];
        }
        x = x.iter().map({ |v| x[*v] }).collect();
    }

    println!("{}", ans + 1);
}

Measured memory_bytes: 6364
#include<iostream>

using namespace std;

long long f[20005];

int main()
{
	long long x;
	cin>>x;
	for(long long i=-200;i<=200;++i)
	  for(long long j=-200;j<=200;++j)
	    if(i*i*i*i*i-j*j*j*j*j==x)
		 {
		 	  cout<<i<<" "<<j<<endl;
		 	  return 0;
		 } 
}

Measured memory_bytes: 3624
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int a; cin >> a;
    REP(i, 0, a){
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;   
}

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

int main(){
	int c[3][3];
	rep(i,3){
		rep(j,3){
			cin >> c[i][j];
		}
	}
	bool ok = true;
	int a = c[0][0] + c[1][1] + c[2][2];
	
	if(a != c[0][1] + c[1][2] + c[2][0]) ok = false;
	if(a != c[0][2] + c[2][1] + c[1][0]) ok = false;
	if(a != c[0][2] + c[1][1] + c[2][0]) ok = false;
	if(a != c[2][2] + c[1][0] + c[0][1]) ok = false;
	if(a != c[1][2] + c[2][1] + c[0][0]) ok = false;
	
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	if(2*c>a+b)
		printf("%d\n",x*a+y*b);
	else if(2*c<=a&&x>y){
		printf("%d\n",x*c*2);
	}
	else if(2*c<=b&&y>x){
		printf("%d\n",y*c*2);
	}
	else{
		int t=x>y?a*(x-y):b*(y-x);
		printf("%d\n",min(x,y)*c*2+t);
	}
	return 0;
	} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{	
    cin>>a;
    b=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<a.size();++i)
	{
		if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
	}
	if(a==b) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 512
import math
def resolve_c():
    a, b = map(int, input().split())
    flg = 0
    xs = math.ceil(a / 0.08)
    ys = math.ceil(b / 0.1)
    xf = math.ceil((a + 1) / 0.08)
    yf = math.ceil((b + 1) / 0.1)

    for i in range(xs, xf, 1):
        for j in range(ys, yf, 1):
            if i == j:
                flg = 1
                print(i)
                break
        else:
            continue
        break
        
    if flg == 0:
        print(-1)
resolve_c()

Measured memory_bytes: 3064
class Dice:
    def __init__(self,faces):
        self.faces = tuple(faces)
    def N(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])
    def S(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])
    def W(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])
    def E(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])
    def number(self, face_id):
        return self.faces[face_id - 1]
dice = Dice(list(map(int, input().split())))
x=input()
 
for i in x:
    if i == "N":dice.N()
    elif i == "S":dice.S()
    elif i == "W":dice.W()
    elif i == "E":dice.E()
print(dice.number(1))

Measured memory_bytes: 5608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

long long f(long long n,long long x){
	if(n<0){
		return -1;
	}else{
		return n/x;
	}
}

int main(){
	long long a,b,x;
	cin >> a >> b >> x;
	long long cnt=f(b,x)-f(a-1,x);
	printf("%lld\n",cnt);
	return 0;
}


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    int cnt = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i]==s[i+1]) cnt++;
    }
    cout << min(n - 1, cnt + 2 * k) << endl;
}


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

void testCase(){
	int n;
    cin>>n;
    string s; cin>>s;
    if(s.length() <= n) cout<<s<<endl;
    else{
        s = s.substr(0, n);
        cout<<s<<"..."<<endl;
    }
}

int main(){
    int t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define MAX 100000

int partition(int*,int,int);
void quickSort(int*,int,int);
int isStable(int *,int *,int);

int B[MAX];
char C[MAX];

int main(){

  //unsigned short *A;
  int A[MAX];

  int i,k=0,n;
  int x,p,q,r;


  scanf("%d",&n);

  p=0;
  r=n-1;

  //A=malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf(" %c %d",&C[i],&A[i]);
    B[i]=i;
  }

  quickSort(A,p,r);


  if(isStable(A,B,n)==0) printf("Not stable\n");
  else printf("Stable\n");


  for(i=0;i<n;i++){
    printf("%c %d\n",C[i],A[i]);
  }
  


  return 0;
  
}


int partition(int* A,int p,int r){
  int i,j,x,mv,bmv;
  char cmv;
  i=p-1;
  x=A[r];

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;

      mv=A[i];
      bmv=B[i];
      cmv=C[i];
      A[i]=A[j];
      B[i]=B[j];
      C[i]=C[j];
      A[j]=mv;
      B[j]=bmv;
      C[j]=cmv;
    }

  }


  mv=A[i+1];
  bmv=B[i+1];
  cmv=C[i+1];
  A[i+1]=A[r];
  B[i+1]=B[r];
  C[i+1]=C[r];
  A[r]=mv;
  B[r]=bmv;
  C[r]=cmv;

  return i+1;
}


void quickSort(int* A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int isStable(int *A,int *B,int n){
  int i;
  for(i=0;i+1<n;i++){
    if(A[i]==A[i+1] && B[i]>B[i+1])return 0;
  }
  return 1;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool d = (a + b + c) >= 22;
  string ans = d ? "bust" : "win";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true) {
        val inStr = readLine() ?: return
        val scores = inStr.split(' ').map { e -> e.toInt() }
        if (scores.all { s -> s == -1 }) {
            // input ends
            return
        }

        val (m, f, r) = scores
        println(judgeGrade(m, f, r))
    }
}

fun judgeGrade(m: Int, f: Int, r: Int): String {
    if (m == -1) {
        return "F"
    }
    if (f == -1) {
        return "F"
    }

    val totalScore = m + f

    return when {
        totalScore >= 80 -> "A"
        totalScore >= 65 -> "B"
        totalScore >= 50 -> "C"
        totalScore >= 30 -> {
            when (r >= 50) {
                true -> "C"
                false -> "D"
            }
        }
        else -> "F"
    }
}



Measured memory_bytes: 34160
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);


		       int hati = sc.nextInt();
		       int juu = sc.nextInt();

		       for(int i = 1; i <= 1000;i++) {
		    	   if((int)(i*0.08) ==hati && (int)(i*0.1) ==juu) {
		    		   System.out.println(i);
		    		   return;
		    	   }
		       }
		       System.out.println("-1");



	}
		}



Measured memory_bytes: 23764
#include<stdio.h>
int main(){
    int a,b,c,i,count;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long t = sc.nextLong();
		long[] a = new long[n];
		for(int i = 0 ; i  <n ; i++) a[i] = sc.nextLong();
		long ans = 0;
		for(int i = 0 ; i < n - 1 ; i++) {
			ans += Math.min(a[i + 1] - a[i], t);
		}
		System.out.println(ans + t);
	}
}

Measured memory_bytes: 84640
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        sc.close();

        // 主処理
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int i = 0; i <= s.length() - t.length(); i++) {
            int count = 0;
            for (int j = 0; j < t.length(); j++) {
                if (cs[i + j] != ct[j]) {
                    count++;
                }
            }
            pq.add(count);
        }
        int result = pq.peek();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35976
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    vector<int> pre(n+1);
    int cur = 0;
    for (int i=0; i<n+1; i++) {
        if (s.at(i) == '0') {
            cur = i;
        }
        pre.at(i) = cur;
    }

    vector<int> res;
    cur = 0;
    while (cur < n) {
        int next = pre.at(min(cur+m, n));
        if (next == cur) {
            cout << -1 << '\n';
            return;
        } else {
            res.push_back(next - cur);
            cur = next;
        }
    }

    for (int i=(int)res.size()-1; i>=0; i--) {
        cout << res.at(i);
        if (i == 0) cout << '\n';
        else cout << ' ';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1480
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
//#define int long long int
int lift[(int)1e5 + 10][20] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vi dis(n);
    FOR(i, n)cin >> dis[i];
    int j = 0;
    int l; cin >> l;
 //   cout << endl << endl;
    FOR(i, n){
       while(j < dis.size()- 1 && dis[j+1] <= dis[i] + l){
        j++;
       } 
       lift[i][0] = j;
//       cout << i << " " << j <<endl;
    }
    for(int i = 1; i <= 16; i++){
        FOR(j, n){
            lift[j][i] = lift[lift[j][i-1]][i-1];
        } 
    }
    //debug("pre done");
    int q;cin >> q;
    int i;
    FOR(xx, q){
        cin >> i >> j;
        if(j < i)swap(i, j);
        i--, j--;
        int ans = 0;
        int bit = 16;
        while(bit >= 0 && i < j){
           if(lift[i][bit] < j){
            i = lift[i][bit];
            ans += (1 << bit);
           } 
           bit--;
        }
        cout << ans + 1;
        cout << "\n";
    }
}




Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    ll ans = INF;
    sort(x.begin(),x.end());
    int max_x = MAX(x);
    for (int i = 1; i<=100;i++){
        ll res = 0;
        rep(j,n){
            res+=pow(x[j]-i,2);
        }
        ans = min(ans,res);
    }
    cout << ans << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

string r_s;

int main(void) {
  // Here your code !
  cin >> s;

  int n = s.size();

  s.push_back('B');

  int i = 0;
  while (i < n - 1) {
    if (s[i] == 'B' && s[i + 1] == 'C') {
      r_s.push_back('D');
      i += 2;
    }
    else {
      r_s.push_back(s[i]);
      i += 1;
    }
  }

  ll cur_a = 0;
  ll cnt = 0;

  for (auto e: r_s) {
    if (e == 'A') {
      cur_a += 1;
    }
    else if (e == 'D') {
      cnt += cur_a;
    }
    else {
      cur_a = 0;
    }
  }

  printf("%lld\n", cnt);

  return 0;
}


Measured memory_bytes: 776
import java.io.*;
import java.util.*;

public class Main{
	public static int count = 0;
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		int max = 0;
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i<n ; i++ ) {
			a[i] = sc.nextInt();
			max = Math.max(max,a[i]);
		}

		countingSort(a,b,max);
		sb.append(b[0]);
		for (int i = 1; i<n ; i++ ) {
			sb.append(" ").append(b[i]);
		}

		System.out.println(sb);
	}


	public static void countingSort(int[] a,int[] b,int max){
		int[] c = new int[max+1];

		for (int j = 0; j<a.length ; j++ ) {
			c[a[j]]++;
		}

		for (int i = 1; i<=max ; i++ ) {
			c[i] = c[i] + c[i-1];
		}

		for (int j = a.length-1; j>=0 ; j-- ) {
			b[c[a[j]]-1] = a[j];
			c[a[j]]--;
		}


	}
}

Measured memory_bytes: 515132
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
const int N=110,M=500010;
const long long mod=1e9+7;
const long double EPS=1e-7;
const int MAX=2e9;
int n,m,k,C[N*2][N*2],hap[N];
vector<int> g[N];
int fa[N],arr[N],dfn[N],bccnum,low[N],cl;
vector<pair<int,int> > bcc[N];
vector<int> hhh[N];
stack<int> sta;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
void Tarjan(int now,int f){
    fa[now] = f;
    low[now] = dfn[now] = ++cl;
    sta.push(now);
    for(int i=0;i<g[now].size();i++){
    	if(g[now][i] == f) continue;
    	if(dfn[g[now][i]] > dfn[now]) continue;
    	if(!dfn[g[now][i]]){
        	Tarjan(g[now][i],now);
        	low[now] = min(low[now],low[g[now][i]]);
    	}
    	else{
        	low[now] = min(low[now],dfn[g[now][i]]);
        	hhh[now].push_back(g[now][i]);
    	}
    }
    if(f == 0 || low[now] >= dfn[fa[now]]){
    	bccnum++;
    	while(true){
        	int k = sta.top();sta.pop();
        	arr[k] = 1;
        	if(fa[k] == 0) break;
        	bcc[bccnum].push_back(make_pair(k,fa[k]));
        	for(int i=0;i<hhh[k].size();i++) bcc[bccnum].push_back(make_pair(k,hhh[k][i]));
        	if(k == now) break;
    	}
    	if(bcc[bccnum].size() == 0) bccnum--;
    }
}
int fast_pow(int now,int pw){
    int ans = 1,dt = now, bit = 1;
    while(bit <= pw){
    	if(bit & pw) ans =1ll*ans*dt%mod; 
    	dt = 1ll*dt*dt%mod; bit<<=1;
    }
    return ans;
}
int solve(int now){
    int ans = 0;
    for(register int i=1;i<=now;i++){
    	ans += fast_pow(k,gcd(now,i));
    	ans %= mod;
    }
    ans = 1ll*ans*fast_pow(now,mod-2)%mod;
    return ans;
}
int main(){
    //freopen("problem.in","r",stdinx);
    //freopen("problem.out","w",stdout);
    scanf("%d%d%d",&n,&m,&k);
    for(register int i=1;i<=m;i++){
    	int u,v; scanf("%d%d",&u,&v);
    	g[u].push_back(v); g[v].push_back(u);
    }
    for(register int i=1;i<=n;i++){
    	if(arr[i]) continue;
    	Tarjan(i,0);
    }
    C[0][0] = 1;
    for(register int i=1;i<=200;i++){
    	C[i][0] = C[i][i] = 1;
    	for(register int j=1;j<i;j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;
    }
    int ans = 1;
    for(register int i=1;i<=bccnum;i++){
    	int flag = 2;
    	for(register int j=0;j<bcc[i].size();j++){
        	if(hap[bcc[i][j].first] && hap[bcc[i][j].second]) flag--;
        	hap[bcc[i][j].first]++; hap[bcc[i][j].second]++;
    	}
    	for(register int j=0;j<bcc[i].size();j++){
        	hap[bcc[i][j].first]--;
        	hap[bcc[i][j].second]--;
    	}
    	if(flag == 1 || flag == 2){
        	if(bcc[i].size() == 1) ans = 1ll*ans*k%mod;
        	else ans = 1ll*ans*solve(bcc[i].size())%mod;
    	}
    	else ans = 1ll*ans*C[bcc[i].size()+k-1][k-1]%mod;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), d = scan.nextInt();
		float[][] array = new float[n][d];
		float root_inside;
		int count=0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < d; j++) {
				array[i][j] = scan.nextInt();
			}
		for (int i_kari = 0; i_kari < n - 1; i_kari++) {

			for (int i = i_kari + 1; i < n; i++) {
				root_inside = 0;
				for (int j = 0; j < d; j++) {
					root_inside += Math.pow((array[i_kari][j] - array[i][j]), 2);
				}
				if(Math.ceil(Math.sqrt(root_inside))-Math.floor(Math.sqrt(root_inside))==0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

const int dh[] = {-1, 0, 1, 0};
const int dw[] = {0, 1, 0, -1};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, H;
    while(cin>>W>>H, W|H){
        vector<vector<int>> field(H, vector<int>(W));
        vector<int> dcost(4);
        
        for(int i=0; i<H; i++)
            for(int j=0; j<W; j++)
                cin >> field[i][j];
        for(int i=0; i<4; i++)
            cin >> dcost[i];
        
        vector<vector<vector<int>>> d(H, vector<vector<int>>(W, vector<int>(4, INF)));
        priority_queue<pair<int, vector<int>>, vector<pair<int, vector<int>>>, greater<pair<int, vector<int>>>> que;
        d[0][0][1] = 0;
        que.push(make_pair(d[0][0][1], vector<int>{0, 0, 1}));
        
        while (!que.empty()) {
            auto v = que.top(); que.pop();
            int cost = v.first;
            int h = v.second[0], w = v.second[1], dir = v.second[2];
            if(d[h][w][dir] != cost)
                continue;
            
            for(int i=0; i<4; i++){
                int ncost;
                if(field[h][w] == i){
                    ncost = cost;
                }else{
                    ncost = cost + dcost[i];
                }
                int ndir = (dir+i)%4;
                int nh = h + dh[ndir];
                int nw = w + dw[ndir];
                if(0<=nh&&nh<H && 0<=nw&&nw<W && d[nh][nw][ndir]>ncost){
                    d[nh][nw][ndir] = ncost;
                    que.push(make_pair(ncost, vector<int>{nh, nw, ndir}));
                }
            }
        }
        
        int ans = INF;
        for(int i=0; i<4; i++)
            ans = min(ans, d[H-1][W-1][i]);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1412
#include<stdio.h>
#define TRUE 1
#define FALSE 0
#define N 8
#define FREE (-1)
#define NOT_FREE 1
int row[N],col[N],dpos[2 * N -1],dneg[2 * N - 1],i,j;
int flag[N][N];

void initialize(){
  int i,j;
  for(i=0;i<N;i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(flag[i][j]){
	if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}


void recursive(int i){
  int j;
  if(i == N){//クイーンの配置に成功
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    //(i,j)が他のクイーンに襲撃されている場合は無視
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i-j+N-1])continue;
    //(i,j)にクイーンを配置する
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    //次の行を試す
    recursive(i + 1);
    //(i,j)にクイーンを取り除く
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  //クイーンの配置に失敗
}

int main(){
  int k,r,c;
  initialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      flag[i][j] = FALSE;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf(" %d %d",&r,&c);
    flag[r][c] = TRUE;
  }
  recursive(0);
  
    return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<stdlib.h>
#include<map>
using namespace std;

bool flg[30];
int main(){
  int i,n;
  for(i=0;i<28;i++){
    scanf("%d",&n);
    n--;
    flg[n]=true;
  }
  for(i=0;i<30;i++){
    if(!flg[i])
      printf("%d\n",i+1);
  }
  return 0;
}

Measured memory_bytes: 0
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def LCS(s, t):
	n, m = len(s), len(t)
	dp = [[0 for i in range(m+1)] for j in range(n+1)]
	for i in range(n+1):
		for j in range(m+1):
			if i == 0 or j == 0:
				dp[i][j] = 0
			elif s[i-1] == t[j-1]:
				dp[i][j] = 1 + dp[i-1][j-1]
			else:
				dp[i][j] = max(dp[i-1][j], dp[i][j-1])
	index = dp[n][m]
	ans = [" "]*index
	i, j = n, m
	while index:
		if s[i-1] == t[j-1]:
			ans[index-1] =  s[i-1]
			index -= 1
			i -= 1; j -= 1
		elif dp[i-1][j] > dp[i][j-1]:
			i -= 1
		else:
			j -= 1
	return(("").join(ans))

def solve():
	s1 = inp().strip(); s2 = inp().strip()
	print(LCS(s1, s2))


if __name__ == "__main__":
	solve()

Measured memory_bytes: 103324
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int inf=1e9+9;
class DINIC
{
public:
 
    queue <int> Q; // queue for bfs
    int n, source, sink; // number of vertices, source, sink
    vector < int > cur, dis;  // current neghbour for dfs, distance from bfs
    vector < vector <int> > cap;  // max capacity
    vector < vector <int> > nei; // neighbours
 
    bool bfs ()
    {
        dis = vector <int> (n+1, -1);
        dis[source] = 0;
        Q.push(source);
        while (!Q.empty())
        {
            int u = Q.front();
            Q.pop();
            for (int v : nei[u])
                if (!~dis[v] && cap[u][v])
                {
                    dis[v]=dis[u]+1;
                    Q.push(v);
                }
        }
        return ~dis[sink];
    }
 
    int dfs (int u, int mincap)
    {
        if (!mincap || u==sink)
            return mincap;
        int res=0;
        for (int i=cur[u]; i<nei[u].size(); i++)
        {
            if (!mincap)
                break;
            else
                cur[u]=i;
            int v = nei[u][i];
            if (dis[v]==dis[u]+1)
            {
                int f = dfs (v, min(mincap, cap[u][v]));
                mincap-=f;
                res+=f;
                cap[u][v]-=f;
                cap[v][u]+=f;
            }
        }
        return res;
    }
 
public:
 
    DINIC (int n, int source, int sink) : n(n), source(source), sink(sink), cap(n+1,vector<int>(n+1,0)), nei(n+1) {}
 
    int flow ()
    {
        int res = 0;
        while (bfs())
        {
            cur = vector<int> (n+1, 0);
            res += dfs(source,inf);
        }
        return res;
    }
 
    void addEdge (int fr, int to, int cap1, int cap2 = 0)
    {
        //printf (">> %d %d %d %d\n",fr,to,cap1,cap2);
        nei[fr].push_back(to);
        nei[to].push_back(fr);
        cap[fr][to]+=cap1;
        cap[to][fr]+=cap2;
    }
};
const int MAX=105;
int a[MAX];

int32_t main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)cin>>a[i];
  DINIC d(n+2,0,n+1);
  int sum=0;
  for (int i=1;i<=n;i++){
  	if (a[i]<=0)d.addEdge(0,i,-a[i]);
  	else d.addEdge(i,n+1,a[i]),sum+=a[i];
  }
  
  for (int i=1;i<=n;i++){
  	for (int j=2*i;j<=n;j+=i)d.addEdge(i,j,inf);
  }
  
  cout<<sum-d.flow();
  return 0;
}


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

string to_string(const string& s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A, typename B>
string to_string(pair<A, B>p){return "("+to_string(p.first)+","+to_string(p.second)+")";}
template <typename A>
string to_string(A v) {
  bool first = true; string res = "{";
  for (const auto &x : v) {
	if (!first) res += ", ";
	first = false;
	res += to_string(x);
  }
  return res+'}';
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) false
#endif

#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;

const int bmx=61;

void upd(vector<ll> &cur,vector<ll> &vals){
	for(auto &i:cur){
		for(int b=bmx-1;b>=0;b--){
			if(i&(1ll<<b)){
				if(vals[b]==-1){
					for(int ind=b-1;ind>=0;ind--){
						if(vals[ind]!=-1) i^=vals[ind];
					}
					vals[b]=i;
					forse(ind,b+1,bmx){
						if(vals[ind]!=-1&&(vals[ind]&(1ll<<b))){
							vals[ind]^=i;
						}
					}
					break;
				}else{
					i^=vals[b];
				}
			}
		}
	}
}

void solve(){
	int n;
	string s;
	cin >> n;
	vector<ll> a(n);
	forn(i,n){
		cin >> a[i];
	}
	cin >> s;

	vector<ll> vals(bmx,-1);
	for(int i=n-1;i>=0;){
		int j=i;
		vector<ll> cur;
		while(j>=0&&s[j]==s[i]){
			cur.pb(a[j]);
			j--;
		}
		if(s[i]=='0') upd(cur,vals);
		else{
			for(auto &i:cur){
				for(int ind=bmx-1;ind>=0;ind--){
					if(vals[ind]!=-1&&i&(1ll<<ind)) i^=vals[ind];	
				}
				if(i!=0){
					cout << "1\n";
					return;
				}
			}
		}
		
		i=j;
	}
	cout << "0\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


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

int main() {
  long double a,b,c;
  cin>>a>>b>>c;
  
  if(a+b+2*sqrt(a*b)<c){
  cout <<"Yes"<<endl;
  }else{
  cout <<"No"<<endl;
  }
  
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;

    int dx = xt - xs;
    int dy = yt - ys;

    // Ls -> Ut
    // Rt -> Ds
    cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';

    // Us -> Lt
    // Dt -> Rs
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');

    cout << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b,c;
	scanf("%d",&n);
	a=n%10;
	n=n/10;
	b=n%10;
	n=n/10;
	c=n%10;
	if(a==1){
		a=9;
	}
	else{
		a=1;
	}
	if(b==1){
		b=9;
	}
	else{
		b=1;
	}
	if(c==1){
		c=9;
	}
	else{
		c=1;
	}
	printf("%d\n",c*100+b*10+a);
	return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;


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

	REP(j, W+2)cout << "#"; cout << endl;
	REP(i, H){
		cout << "#";
		REP(j, W){ char c; cin >> c; cout << c; } 
		cout << "#"; cout << endl;

	}
	REP(j, W+2)cout << "#"; cout << endl;

	return 0;
}

//int mainA(){
//	int a[] = { 1, 3, 5, 7, 8, 10, 12 };
//	int b[] = { 4, 6, 9, 11 };
//	int c[] = { 2 };
//
//	int x, y;
//	cin >> x >> y;
//	int xx = -1, yy = -1;
//
//	REP(i, 7){
//		if (x == a[i])xx = 0;
//		if (y == a[i])yy = 0;
//	}
//	REP(i, 4){
//		if (x == b[i])xx = 1;
//		if (y == b[i])yy = 1;
//	}
//	
//		if (x == 2)xx = 2;
//		if (y == 2)yy = 2;
//		cout << ((xx == yy) ? "Yes" : "No") << endl;
//	
//
//	return 0;
//}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
        cin>>n;
        ll i,arr[n+1],pos;
        ll maxx=-mod,max2=-mod;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            if(arr[i]>maxx)
            {
                maxx=arr[i];
                pos=i;
            }
            else if(arr[i]<=maxx)
            {
                max2=max(max2,arr[i]);
            }
        }
        for(i=0;i<n;i++)
        {
            if(i==pos)
                cout<<max2<<endl;
            else
                cout<<maxx<<endl;
        }
    return 0;
}

Measured memory_bytes: 3200
N,M=map(int,input().split())
ans=[0 for i in range(N+1)]
true=[True for i in range(N+1)]
for i in range(M):
  a=int(input())
  true[a]=False
mod=10**9+7
ans[0]=1
ans[1]=1
for i in range(2,N+1):
  for j in range(i-2,i):
    if true[j]:
      ans[i]+=ans[j]%mod
print(ans[N]%mod)

Measured memory_bytes: 13588
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  long long int a,b;
  cin >> a >> b;

  if(a <= 0 && b >= 0){
    cout << "Zero" << endl;
    return 0;
  } else if(a > 0) {
    cout << "Positive" << endl;
    return 0;
  } else {
    if((b - a + 1)%2 == 0){
      cout << "Positive" << endl;
      return 0;
    } else {
      cout << "Negative" << endl;
      return 0;
    }
  }

  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int N; cin>>N;
  vector<int> H(N); rep(i,N)cin>>H.at(i);

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

  dp.at(1) = fabs(H.at(1)-H.at(0));

  for(int i = 2; i <= N-1; i++){
    dp.at(i) = min(dp.at(i-2)+fabs(H.at(i)-H.at(i-2)),dp.at(i-1)+fabs(H.at(i)-H.at(i-1)));
  }

  cout<<dp.at(N-1)<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
typedef pair<int,int> pii;
vector<pii>V[N];
int n, m, s[3], col[N], c;
long long ans;

bool Dfs (int u) {
	bool o = 0; int v, w;
	++s[col[u]];
	for (auto p : V[u]) {
		v = p.first; w = (p.second + 3 + col[u]) % 3; if (p.second == 1) ++c;
		if (col[v] == -1) col[v] = w, o |= Dfs(v); else if (col[v] != w) o |= 1;
	}
	return o;
}

int main () {
	scanf("%d%d", &n, &m); memset(col, -1, sizeof col);
	for (int i = 1, u, v; i <= m; ++i)
	scanf("%d%d", &u, &v), V[u].emplace_back(pii(v, 1)), V[v].emplace_back(pii(u, -1));
	for (int i = 1; i <= n; ++i) if (col[i] == -1) {
		s[0] = s[1] = s[2] = c = 0;
		if (col[i] = 0, Dfs(i)) ans += 1ll * (s[0] + s[1] + s[2]) * (s[0] + s[1] + s[2]);
		else if (s[0] && s[1] && s[2]) ans += 1ll * s[0] * s[1] + 1ll * s[1] * s[2] + 1ll * s[2] * s[0];
		else ans += c;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 10752
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    int ans = a*x+b*y;
    ans = min(ans, c*2*x + (x>=y? 0 : (y-x)*b));
    ans = min(ans, c*2*y + (x<=y? 0 : (x-y)*a));

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7



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

	//idx, sum
	vector<pair<ll, ll> > memo(M+1, make_pair(-1, -1));


	ll idx = 0;
	ll cur = X;
	ll cursum = X%M;
	ll checkloop = true;
	while(idx < N - 1) {
		//cout << idx << " " << cur << " " << cursum << endl;
		if(checkloop && memo[cur].first != -1) {
			//ワープ
			//cout << "wapu" << endl;
			checkloop = false;
			ll lastidx = memo[cur].first;
			ll interval = idx - lastidx;
			ll addnum = cursum - memo[cur].second;
			ll loopnum = max(((N - idx) / interval - 1), 0ll);

			//cout << "interval = " << interval << endl;
			//cout << "addnum = " << addnum << endl;
			//cout << "loopnum = " << loopnum << endl;
			
			idx += loopnum * interval;
			cursum += loopnum * addnum;

			continue;
		}
		memo[cur].first = idx;
		memo[cur].second = cursum;


		cur = (cur * cur) % M;
		cursum += cur;

		idx++;
	}

	cout << cursum << endl;



}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cout << #x << " " << x << "\n"; cout.flush();
#define debugtwo(x) cout << #x << "-------------" << "\n";for(auto &it: x) cout << it << " ";cout << "\n"; cout.flush();
#define debugthree(x, i, j) cout << #x << "------------" << "\n";cout << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cout << x[k] << " ";cout << "\n"; cout.flush();



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
		
		
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a) * b << endl;
	return 0;	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
vector< pair <ll, ll> > b, a;
bool solve()
{
    for (ll i = 0; i < n; ++i)
    {
        if (a[i].first > b[i].first) return false;
    }
    for (ll i = 0; i + 1 < n; ++i)
    {
        if (a[i + 1].first <= b[i].first) return true;
    }
    ll cnt = 0;
    for (ll i = 0; cnt == 0 || i != 0; ++cnt)
    {
        i = a[i].second;
    }
    return cnt != n;
}
int main()
{
    scanf("%d",&n);
    b.resize(n);
    for (ll i = 0; i < n; ++i) cin >> b[i].second;
    for (ll i = 0; i < n; ++i) cin >> b[i].first;
    sort(b.begin(), b.end());
    a.resize(n);
    for (ll i = 0; i < n; ++i) a[i] = make_pair(b[i].second, i);
    sort(a.begin(), a.end());
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[200003];
ll n,m;
bool vis[1009][1009];
struct threeElements{
int _1st,_2nd,_3rd;
};
int read(){int x;cin>>x;return x;}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    n=read();
    for(int i=0;i<n;i++)
        a[i]=read();
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            for(int k=j;k<n;k++)
            {
                int x=a[i],y=a[j],z=a[k];
                if(x!=y&&y!=z&&x!=z)
                {
                    if(x+y>z&&x+z>y&&y+z>x)
                        ans++;
                }
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,p;
	cin >> n >> p;
	map <ll,ll> m;
	for(ll i = 2 ; i*i <= p ; i++)
	{
		while(p % i == 0)
		{
			m[i]++;
			p /= i;
		}
	}
	if(p > 1)
		m[p]++;
	ll ans = 1;
	for(auto i = m.begin() ; i != m.end() ; i++)
	{
		ans *= pow(i->first,(i->second/n));
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 1e5 + 5;
int n, k;
int a[105];
int dp[maxn];

int main () {
    scan2(n, k);
    FORN(i, 1, n) scan1(a[i]);
    FORN(i, 1, k) {
        bool check = false;
        FORN(j, 1, n) {
            if ( i - a[j] >= 0 && dp[i-a[j]] == 0 ) {
                check = true;
                break;
            }
        }
        if ( check ) dp[i] = 1;
        else dp[i] = 0;
    }
    if ( dp[k] ) printf("First\n");
    else printf("Second\n");
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>

using namespace std ;

int main(void){
    string S,T;
    char tmp;
    bool flag=false;

    cin >> S >> T;
    
    for(int i=0; i<S.size(); i++){
        if(S==T){
            flag=true;
            break;
        }

        // tmp = S[S.size()-1];
        // for(int j=S.size()-2; j>0; j++){
        //     S[j] = S[j-1];
        // }
        // S[0] = tmp;
        S = S.back() + S.substr(0, S.size()-1);

    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main()
{
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
        for(int k=0;k<=c;k++)
    {
        if(i*500+j*100+k*50==x) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
		int K,S;
		int cnt = 0;
		cin >> K>>S;

		for (int x = 0; x <= K; x++)
		{
			for (int y = 0; y <= K; y++)
			{
				int z = S - x - y;
				if (z>=0&&z<=K )
				{
					cnt++;
				}
			}
		}

		cout << cnt << endl;
		
		return 0;
}

Measured memory_bytes: 256