akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<vector<int>> G(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> P(K);
    P[0]=1;
    rep(i,K-1){
        P[i+1]=P[i]*(K-2-i);
        P[i+1]%=MOD;
    }
    int s0=G[0].size();
    ll ans=K;
    if (s0>K-1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,s0){
        ans*=K-i-1;
        ans%=MOD;
    }
    rep2(i,1,N){
        int s=G[i].size();
        if (s>K-1){
            cout << 0 << endl;
            return 0;
        }
        ans*=P[s-1];
        ans%=MOD;
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    
    int l[N];
    int r[N];
    for(int i = 0; i < N; i++) {
        cin >> l[i] >> r[i];
    } 

    int a[N];
    for(int i = 0; i < N; i++) {
        a[i] = r[i] - l[i] + 1;
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += a[i];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
IP2(n,r);
if(n<10)
r+=100*(10-n);
cout<<r;
nl;
return 0;
}	


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni(), Q = in.ni();
        long[][] map = new long[n][n];
        int l, r, p, q;
        for (int i = 0; i < m; i++) {
            l = in.ni()-1;
            r = in.ni()-1;
            map[l][r]++;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n-1; j++) {
                map[i][j+1] = map[i][j]+map[i][j+1];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            p = in.ni()-1;
            q = in.ni()-1;
            int ans = 0;
            for (int j = p; j <= q; j++) {
                ans += map[j][q];
            }
            sb.append(ans+"\n");
        }
        out.print(sb);
    }
    public static void print2d(long[][] a){
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.length; i++) {
            if(i!=0) sb.append("\n");
            for (int j = 0; j < a[0].length; j++) {
                if(j!=0)sb.append(' ');
                sb.append(a[i][j]);
            }
        }
        System.out.println(sb.toString());
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 61948
package main

import "fmt"

func main() {
	var n, s int
	fmt.Scanf("%d %d", &n, &s)
	s /= 1000
	for x := 0; x <= n; x++ {
		for y := 0; y <= n-x; y++ {
			z := s - 10*x - 5*y
			if z == n-x-y {
				fmt.Println(x, y, z)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
package main
 
import (
	"fmt"
)
 
func main() {
	var (
		a int
		b int
	)
	var o = -1
	fmt.Scanf("%d %d", &a, &b)
	if a <= 9 && b <= 9 {
		o = a * b
	}
	fmt.Print(o)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef struct _dot{
    int x;
    int y;
}Dot;

double My_Distance(Dot a,Dot b){
    return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

int P(int N){
    
    int ans = 1;
    for(int i=1;i<=N;i++) ans *= i;
    return ans;
}

int main(){
    
    int N; cin >> N;
    double sum = 0;
    Dot data[N];
    vector<int> one_case;
    for(int i=0;i<N;i++){ cin >> data[i].x; cin >> data[i].y; }
    for (int i=0;i<N;i++) { one_case.emplace_back(i); }
 
    do {
        int size = one_case.size();
        for(int i=0;i<size-1;i++){
            sum += My_Distance(data[one_case[i]],data[one_case[i+1]]);
        }
    } while (next_permutation(one_case.begin(), one_case.end()));
    
    printf("%.10f\n",sum/P(N));
}

Measured memory_bytes: 3860
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b {
		fmt.Println(c)
	} else if a == c {
		fmt.Println(b)
	} else {
		fmt.Println(a)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

int n,m,a[1100], b[1100];bool c[1100][20];
int dp[10000];
signed main(){
  cin>>n>>m;
  rep(i,10000)dp[i] = INF;
  dp[0] = 0;
  rep(i,m){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      int cc;cin>>cc;cc--;
      c[i][cc] = true;
    }
  }
  rep(bit,1<<n){
    rep(i,m){
      int bb = bit;
      rep(j,n){
        if(c[i][j]){
          bb |= (1<<j);
        }
      }
      chmin(dp[bb], dp[bit] + a[i]);
    }
  }
  cout << (dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  rep(i, n) cin >> a[i];

  vector<string> b(m);
  rep(i, m) cin >> b[i];

  rep(i, n-m+1) {
    rep(j, n-m+1) {
      bool flag = true;
      rep(x, m) {
        rep(y, m) {
          if (a[i+x][j+y] != b[x][y]) flag = false;
        }
      }
      if (flag) {
        puts("Yes");
        return 0;
      }
    }
  }

  puts("No");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read () {
	int s = 0 , w = 1;
	char ch = getchar ();
	while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}
	while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}
	return s * w;
}
const int N = 2e5 + 10;
int n , k;
int A[N] , F[N];
inline bool cmp ( int x , int y ) {
	return x > y;
}
inline bool check ( int mid ) {
	int cnt = 0;
	for ( int i = 1 ; i <= n ; i++ ) 
		cnt += max ( 0ll , A[i] - mid / F[i] );
	if ( cnt <= k ) 
		return true;
	else 
		return false;
}
signed main ( void ) {
	n = read () , k = read ();
	for ( int i = 1 ; i <= n ; i++ ) 
		A[i] = read ();
	for ( int i = 1 ; i <= n ; i++ ) 
		F[i] = read ();
	sort ( A + 1 , A + 1 + n );
	sort ( F + 1 , F + 1 + n , cmp );
	
	
//	for ( int i = 1 ; i <= n ; i++ ) 
//		printf ( "%lld%c" , A[i] , i == n ? '\n' : ' ' );
//	for ( int i = 1 ; i <= n ; i++ ) 
//		printf ( "%lld%c" , F[i] , i == n ? '\n' : ' ' );
//	for ( int i = 1 ; i <= n ; i++ ) 
//		printf ( "%lld%c" , A[i] * F[i] , i == n ? '\n' : ' ' );
	
	int l = 0 , r = 1e16;
	
	while ( l <= r ) {
		int mid = ( l + r ) >> 1;
		if ( check ( mid ) ) 
			r = mid - 1;
		else 
			l = mid + 1;
	}
	
	printf ( "%lld\n" , l );

	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	ll ans = 1;
	stack<int> st;
	REP(i, n){
		if(s1[i] == s2[i]) st.push(1);
		else{
			st.push(2);
			i++;
		}
	}
	int x = st.top();
	st.pop();
	if(x == 1) ans = 3;
	else ans = 6;
	while(st.size()){
		int y = st.top();
		st.pop();
		if(x == 1) ans = (ans * 2) % MOD;
		if(x == 2 && y == 2) ans = (ans * 3) % MOD;
		x = y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float,input().split()))

dp = [[0]*(N+1) for i in range(N+1)] #dp[投げた枚数][表になった回数] = 確率
dp[0][0] = 1.0

for i in range(N):
  for j in range(i+1):
    dp[i+1][j+1] += dp[i][j]*p[i]
    dp[i+1][j] += dp[i][j]*(1-p[i])

ans = 0
for j in range(N+1):
  if j >= N/2:
    ans += dp[-1][j]
print(ans)

Measured memory_bytes: 256008
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

INF = 10000

ans = INF
for bit in range(1 << (h - 1)):

    # 横線でグループ化
    id = [0] * h
    group_idx = 0
    for i in range(h):
        id[i] = group_idx
        if (bit >> i) & 1:
            group_idx += 1

    group_num = group_idx + 1
    cnt = [[0] * w for _ in range(group_num)]
    for i in range(h):
        for j in range(w):
            cnt[id[i]][j] += int(s[i][j])

    # グループ化した際に、1列でkを超えてるならこの縦の区切り方はそもそも無理
    flag = True
    for g in range(group_num):
        for j in range(w):
            if cnt[g][j] > k:
                flag = False
    if not flag:
        continue

    divnum = group_num - 1
    now = [0] * group_num
    cur = 0
    while cur < w:
        for g in range(group_num):
            now[g] += cnt[g][cur]
            if now[g] > k:
                divnum += 1
                now = [0] * group_num
                cur -= 1
                break
        cur += 1
    ans = min(ans, divnum)

print(ans)


Measured memory_bytes: 70984
#include <stdio.h>
#include <math.h>

int main(){
    int length_x, length_y, water_v;
    scanf("%d %d %d", &length_x, &length_y, &water_v);

    long double thete;
    if (water_v > length_x * length_x * length_y / 2){
        thete = 180.0 * atan(2.0 * (long double) (length_x * length_x * length_y - water_v) / (long double) (length_x * length_x * length_x)) / M_PI;
    } else {
        thete = 180.0 * atan((long double) (length_x * length_y * length_y) / (long double) water_v / 2.0) / M_PI;
    }
    printf("%Lf", thete);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int main(){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double ans=0;
    double H_r,M_r;
    H_r = (double)H*30.0+M*0.5;
    M_r = (double)M*6.0;
    double d_r =(double)abs(H_r-M_r);
    if(d_r>180)d_r =360.0-d_r;
    // cout << (double)A*(double)A << (double)B*(double)B << endl;

    ans =(double)sqrt((double)A*(double)A + (double)B*(double)B -2.0*(double)A*(double)B*(double)cos((double)d_r*M_PI/180.0));
    cout << fixed << setprecision(20) << ans << endl;
    

    return 0;
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, d, a, i;
    cin >> n >> k;
    vb ok(n, false);

    for(i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> a;
            a--;
            ok[a] = true;
        }
    }

    int ans = 0;
    for(i=0;i<n;i++)
        if(!ok[i]) ans++;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3660
using System;

public class hello
{
    public static void Main()
    {
        var count = 1;
        var n = 1;
        while (n != 0)
        {
            n = int.Parse(Console.ReadLine().Trim());
            if (n!=0)  Console.WriteLine("Case {0}: {1}", count, n);
            count += 1;
        }

    }
}

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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

int main(){
   ll N; cin >> N;
   ll M = 0, m = INF;
   REP(i, N){
      ll a; cin >> a;
      if (a > M) M = a;
      if (a < m) m = a;
   }
   cout << M - m << endl;

}

Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
ans_arr = []
if n % 2 != 0
  arr.each.with_index do |num,i|
    if i % 2 == 0
      ans_arr.unshift(num)
    else
      ans_arr.push(num)
    end
  end
else
  arr.each.with_index do |num,i|
    if i % 2 != 0
      ans_arr.unshift(num)
    else
      ans_arr.push(num)
    end
  end
end
puts ans_arr.join(' ')


Measured memory_bytes: 39228
#include<iostream>

using namespace std;

int main() {
  int r, d, x2000;
  cin >> r >> d >> x2000;
  int x = x2000;
  for (int i = 0; i < 10; i++) {
    x = x * r - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
s = input()
t = input()
d = {}

for i in range(len(s)):
    if s[i] in d:
        d[s[i]] += [i]
    else:
        d[s[i]] = [i]

count = 0
cur = -1
for i in t:
    if i not in d:
        print(-1)
        exit()
    if cur < d[i][-1]:
        cur = d[i][bisect_right(d[i], cur)]
        continue
    else:
        count += 1
        cur = d[i][0]
print(count*len(s)+cur+1)

Measured memory_bytes: 7540
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    for (int i = 0; i <= s.size()- t.size(); i++) {
        int count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (t.at(j) != s.at(i + j)) {
                count++;
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1,M1,H2,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << max(0,(H2-H1)*60 + (M2-M1) - K) << endl;
}



Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<int,int>mp;
	for (int i=0;i<n;i++)
	{
		int y;
		cin>>y;
		if (mp[y]==1)  
		{
			cout<<"NO";
			re 0;
		}
		mp[y]=1;
	}
	cout<<"YES";
	re 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    ll ans[n+1] = {0};

    for(ll x = 1; x <= 100; x++){
        for(ll y = 1; y <= 100; y++){
            for(ll z = 1; z <= 100; z++){
                ll val = x*x + y*y + z*z + x*y + y*z + x*z;
                if(val <= n) ans[val]++;
            }
        }
    }
    loop(i,1,n+1){
        print(ans[i]);
    }

}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3724
from bisect import bisect
D = [0.2,0.6,1.1]
L = [0]*4
R = [0]*4
while True:
    try:
        left,right = map(float,raw_input().split())
    except:
        break
    L[bisect(D,left)] += 1
    R[bisect(D,right)] += 1
for left,right in zip(L,R)[::-1]:
    print left,right

Measured memory_bytes: 4316
N, K = map(int, input().split())
S = input()
Nums = []
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
ans = 0
# 尺取り法 forループの外側にleft, rightを持つ
left = 0
right = 0
tmp = 0 # [left, right)のsum
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    # 次のleft, rightを計算する
    Nextleft = i
    Nextright = min(i + Add, len(Nums))
    # 左端を移動する
    while Nextleft > left:
        tmp -= Nums[left]
        left += 1
    # 右端を移動する
    while Nextright > right:
        tmp += Nums[right]
        right += 1
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 4092
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
int s[200000 + 10];
int n, k;

int main() {
	scanf("%d%d", &n, &k);
	int cnt = 0;
	map<int, int> m;
	for (int i = 1;i <= n;i++) {
		int t;
		scanf("%d", &t);
		if (m.count(t))s[m[t]]++;
		else {
			m[t] = cnt;
			s[cnt++] = 1;
		}
	}
	sort(s, s + cnt);
	int ans = 0;
	for (int i = 0;i < cnt - k;i++)ans += s[i];
	printf("%d", ans);
	return 0;
}

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

#ifdef STEVEN
#define pp(...) cerr << "\t[" << #__VA_ARGS__ << "]:\t", dbg_out(__VA_ARGS__)
#define ppp(x) cerr << x << "\n"
#else
#define pp(...)
#define ppp(...)
#endif
using namespace std;
// ====

typedef long long ll;
const int MAXN = 1000100;

int main() {
  auto d = [&](int a, int b) -> int {
    return abs(a - b);
  };
  int n, x, y;
  cin >> n >> x >> y;
  if (x > y) swap(x, y);
  vector<int> ans(n + 1);
  for(int i = 1; i <= n; ++i) {
    for(int j = i + 1; j <= n; ++j) {
      int dst = min(d(i, j), d(i, x) + d(y, j) + 1);
      ++ans[dst];
    }
  }
  for (int i = 1; i < n; ++i) {
    cout << ans[i] << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a, b, k;
    cin >> a >> b >> k;

    if (a + b <= k) {
        cout << 0 << " " << 0 << endl;
    } else if (a + b > k && k <= a) {
        cout << a - k << " " << b << endl;
    } else if (a + b > k && a < k) {
        cout << 0 << " " << b - k + a << endl;
    }

    return 0;
}

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

int gcd(int a, int b);

int main(void){
    int N, X, x;
    int D, i;
    scanf("%d %d %d", &N, &X, &x);
    D = abs(X - x);
    for(i = 1; i < N; i++){
        scanf("%d", &x);
        if(D > abs(X - x)){
            D = gcd(D, abs(X - x));
        }else{
            D = gcd(abs(X - x), D); 
        }
    }
    printf("%d\n", D);
    return 0;
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}


void solve(){
    ll n;
    cin>>n;
    Vec<1,ll> a(n),b(n),c(n);
    f(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    Vec<2,ll> dp(n,3);
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    f(i,1,n){
        dp[i][0] = max(dp[i][0], dp[i-1][1]+a[i]);
        dp[i][0] = max(dp[i][0], dp[i-1][2]+a[i]);

        dp[i][1] = max(dp[i][1], dp[i-1][0]+b[i]);
        dp[i][1] = max(dp[i][1], dp[i-1][2]+b[i]);

        dp[i][2] = max(dp[i][2], dp[i-1][1]+c[i]);
        dp[i][2] = max(dp[i][2], dp[i-1][0]+c[i]);
    }
    ll mx = 0;
    mx = max(mx,dp[n-1][0]);
    mx = max(mx,dp[n-1][1]);
    mx = max(mx,dp[n-1][2]);
    cout<<mx<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second

int main(){
    int i,j;
    int n;

    cin>>n;
    int a[n];
    int sum=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    int f=90000000;
    for(i=0;i<n;i++){
        if(f>abs(sum-n*a[i])) f=abs(sum-n*a[i]);
    }
    for(i=0;i<n;i++){
        if(f>=abs(sum-n*a[i])) {
            cout<<i<<endl;
            return 0;
        }
    }
    


    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(2, n):
    k = i - 1
    for j in range(i):
        while k > j and a[k] > a[i] - a[j]:
            k -= 1
        if k < j:
            k = j
        ans += i - k - 1

print(ans)


Measured memory_bytes: 42476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
   string s;
   cin>>s;
   
   int n=s.size();
   ll sum=0;
   rep(i,n){
       sum+=s[i]-'0';
   }

   if(sum%9==0) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 3720
import sys
from collections import defaultdict

readline = sys.stdin.readline


def prime_factorize(n):
    a = defaultdict(int)
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a


def isqrt(n):
    if n > 0:
        x = 1 << (n.bit_length() + 1) // 2
        y = (x + n // x) // 2
        while y < x:
            x = y
            y = (x + n // x) // 2
        return x
    elif n == 0:
        return 0
    else:
        raise ValueError("isqrt() argument must be nonnegative")


def main():
    N = int(readline())
    c = prime_factorize(N)

    ans = 0
    for power in c.values():
        ans += (isqrt(1 + 8 * power) - 1) // 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9516
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
vector<ll>adj[200005];
vector<ll>dis(200005,-1);

ll dfs(ll s)
{
	if(dis[s]!=-1) return dis[s];
	ll cnt=0;
	for(ll x:adj[s])
	{
		cnt=max(cnt,dfs(x)+1);
	}
	dis[s]=cnt;
	return dis[s];
}
int main()
{
    fast;
	ll n,m; cin>>n>>m;
	fo(i,0,m)
	{
		ll x,y; cin>>x>>y; 
		x--; y--;
		adj[x].pb(y);
	}
	ll ans=0;
	fo(i,0,n)
		ans=max(ans,dfs(i));
	cout<<ans;
}

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

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

        string S;
        cin >>S;
        
      
            if(S[K-1]=='A'){
                S[K-1]='a';
            }else if(S[K-1]=='B'){
                S[K-1]='b';
            }else if(S[K]=='C'){
                S[K-1]='c';
              
            
        }
        cout << S;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    int a,b;
    cin >> a >> b;
    cout << (H-a)*(W-b) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
S = deque([input()])
Q = int(input())
Query = list(input().split() for i in range(Q))
sentou = 0
for i in range(Q):
    if Query[i][0] == "1":
        sentou += 1
    if Query[i][0] == "2":
        if Query[i][1] == "1":
            if sentou % 2:
                S.append(Query[i][2])
            else:
                S.appendleft(Query[i][2])
        if Query[i][1] == "2":
            if sentou % 2:
                S.appendleft(Query[i][2])
            else:
                S.append(Query[i][2])
ans = ""
for i in S:
    ans += i
if sentou % 2:
    print(ans[::-1])
else:
    print(ans)

Measured memory_bytes: 42288
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll N;cin>>N;
  ll MOD=1e9+7;
  
  ll a10=1,a9=1,a8=1;
  while(N){
    a10*=10;
    a9*=9;
    a8*=8;
    a10%=MOD;
    a9%=MOD;
    a8%=MOD;
    N--;
  }
  
  cout<<((a10-2*a9+a8)%MOD+MOD)%MOD<<endl;
}

Measured memory_bytes: 3628
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,ta,ao = inpl()
ta -= 1; ao -= 1
g = [[] for i in range(n)]
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ta_dist = [None] * n
ta_dist[ta] = 0
ao_dist = [None] * n
ao_dist[ao] = 0
def ta_dfs(node):
    for v in g[node]:
        if ta_dist[v] != None: continue
        ta_dist[v] = ta_dist[node] + 1
        ta_dfs(v)
def ao_dfs(node):
    for v in g[node]:
        if ao_dist[v] != None: continue
        ao_dist[v] = ao_dist[node] + 1
        ao_dfs(v)
ao_dfs(ao)
ta_dfs(ta)
res = 0
for i in range(n):
    if ta_dist[i] > ao_dist[i]: continue
    res = max(res, ao_dist[i])
print(res-1)

Measured memory_bytes: 103712
/*
    Code written by Talant I.D.
*/

#include <bits/stdc++.h>

using namespace std;

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

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

inline bool isprime(int n){
    if(n < 2 || (n%2 == 0 && n != 2)) return false;
    for(int i = 3; i*i <= n; i += 2)
        if(n%i == 0) return false;
    return true;
}

int main(){
    do_not_disturb

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        a -= d;
    }
    if(c <= 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3640
// 2015/06/02 Tazoe

#include <iostream>
using namespace std;

// Nodeクラス
class Node{
public:
	Node* prev;	// 前のノードへのポインタ
	Node* next;	// 次のノードへのポインタ
	int data;	// データ
	Node(){prev = 0; next = 0; data = 0;}		// デフォルトコンストラクタ
};

// Listクラス
class List{
private:
	Node head;	// ヘッドノード（ダミー）
public:
	List(){head.prev = &head; head.next = &head;}	// デフォルトコンストラクタ
	Node* search(int x);		// 探索
	int insert(int x);		// 挿入
	int del(int x);			// 削除
	int deleteFirst();		// 先頭を削除
	int deleteLast();		// 末尾を削除
	void print();			// 表示
};

// searchメソッド（探索）
Node* List::search(int x)
{
	for(Node* p=head.next; p!=&head; p=p->next){
		if(p->data==x)
			return p;	// 見つかった
	}

	return 0;			// 見つからなかった
}

// insertメソッド（挿入）
int List::insert(int x)
{
	Node* p = new Node();

	if(p==0)
		return -1;		// メモリ確保エラー

	Node* q = &head;
	Node* r = head.next;

	p->prev = q;
	p->next = r;
	p->data = x;

	q->next = p;
	r->prev = p;

	return 0;			// 正常終了
}

// delメソッド（削除）
int List::del(int x)
{
	Node* p = search(x);

	if(p==0)
		return -2;		// 探索エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// deleteFirstメソッド（先頭を削除）
int List::deleteFirst()
{
	Node* p = head.next;

	if(p==&head)
		return -2;		// エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// deleteLastメソッド（末尾を削除）
int List::deleteLast()
{
	Node* p = head.prev;

	if(p==&head)
		return -2;		// エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// printメソッド（表示）
void List::print()
{
	for(Node* p=head.next; p!=&head; p=p->next){
		cout << p->data;

		if(p->next!=&head){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
}


// main関数
int main()
{
	List L;

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		char com[20];		// C文字列
		cin >> com;

		if(com[0]=='i'){
			int x;
			cin >> x;

			L.insert(x);
		}
		else if(com[6]=='F'){
			L.deleteFirst();
		}
		else if(com[6]=='L'){
			L.deleteLast();
		}
		else{
			int x;
			cin >> x;

			L.del(x);
		}
	}

	L.print();

	return 0;
}

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

int main()
{
	string s[500];
	int n,  b, c, d, e = 0, f, g, h;
	cin >> n;
	for (b = 0; b < n; b++)
	{
		
		cin >> s[b];

		

	}
	for ( b = 0; b < 1; b++)
	{
		for ( f = 0; f < n; f++)
		{
			g = 0;
		
			for (c = 0; c < n; c++)
			{
				for (d = 0; d < n; d++)
				{
					if (s[(c+f)%n][(d + b) % n] != s[(d+f)%n][(c + b) % n])
					{
						g = 1;
						break;
					}
					if (c == n - 1 && d == n - 1)
					{
						e++;
					}
				}
				if (g==1)
				{
					break;
				}
			}

		}
	}
	/*for (b = 1; b < n; b++)
	{
		for (c = 0; c < n; c++)
		{
			for (d = 0; d < n; d++)
			{
				if (s[(c+b)%n][d % n] != s[(d+b)%n][(c) % n])
				{
					break;
					break;
				}
				if (c == n - 1 && d == n - 1)
				{
					e++;
				}
			}
		}
	}*/
	cout << e*n << endl;

	return 0;
}

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

using namespace std;

void Main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += l[i];
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d,ac,ad,bc,bd;
	cin>>a>>b>>c>>d;
	ac=a*c;
	ad=a*d;
	bc=b*c;
	bd=b*d;
	cout<<max(ac,max(ad,max(bc,bd)));
	return 0;
} 

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll h,w,m;
  cin >> h >> w >> m;
  set<pair<ll,ll>> st;
  vector<pair<ll,ll>> vec1(h),vec2(w);
  rep(i,h){
    vec1[i].first = 0;
    vec1[i].second = i;
  }
  rep(i,w){
    vec2[i].first = 0;
    vec2[i].second = i;
  }
  rep(i,m){
    cin >> t1 >> t2;
    t1--,t2--;
    vec1[t1].first++;
    vec2[t2].first++;
    st.insert({t1,t2});
  }
  sort(all(vec1),greater<pair<ll,ll>>());
  sort(all(vec2),greater<pair<ll,ll>>());
  ll ans = vec1[0].first + vec2[0].first;
  ll piv1 = vec1[0].first;
  ll piv2 = vec2[0].first;
  bool can = false;;
  rep(i,h){
    if(can){
      break;
    }
    rep(j,w){
      if(vec1[i].first == piv1 && vec2[j].first == piv2){
        if(st.find({vec1[i].second,vec2[j].second}) == st.end()){
          //cout << i << " " << j << endl;
          can = true;
          break;
        }
      }else{
        break;
      }
    }
  }
  if(!can){
    ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 31484
n = int(input())
p = [int(z) for z in input().split()]
k = sorted(p)
poss = False

for i in range(n):
      for j in range(i+1,n):
            new = p[:i]+[p[j]]+p[i+1:j]+[p[i]]+p[j+1:]
            #print(new)
            if (new)==k:
                  poss = True
                  break
if (p==k):
      poss=True

if (poss):
      print("YES")
else:
      print("NO")


Measured memory_bytes: 9132
#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz size()
#define ft front
#define pu push
#define ty empty
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int m5=100042;
int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<" "<<c<<" ";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b && a > c){ if (b < c){ printf("%d %d %d\n", b, c, a); }
	else{printf("%d %d %d\n", c, b, a);} }
	else if (b>a && b>c){ if (a<c){ printf("%d %d %d\n", a, c, b); } 
	else{ printf("%d %d %d\n", c,a,b); } }
	else if (c>a && c>b){ if (a<b){ printf("%d %d %d\n", a, b, c); } 
        else{ printf("%d %d %d\n",b,a,c); } }
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main(){
  int N,A[100010],abs_min=1000000010,cnt=0;
  long long sum=0;
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];

  for(int i=0;i<N;i++){
    abs_min=min(abs_min,abs(A[i]));
    if(A[i]<0) cnt++;
  }

  for(int i=0;i<N;i++) sum+=abs(A[i]);
  if(cnt%2==0) cout << sum << endl;
  else cout << sum-abs_min*2 << endl;
  return 0;
}


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

int r, D, x2000;

int main() {
  cin>>r>>D>>x2000;
  for(int i=0; i<10;i++){
    x2000*=r;
    x2000-=D;
    cout<<x2000<<"\n";
  }
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    x: usize,
    y: usize,
    z: usize,
    k: usize,
    mut xs: [usize;x],
    mut ys: [usize;y],
    mut zs: [usize;z]
  }
  
  let mut doubles: Vec<usize> = vec![0;x*y];
  for i in 0..x {
    for ii in 0..y {
      doubles[i*y + ii] = xs[i] + ys[ii];
    }
  }
  doubles.sort();
  doubles.reverse();

  let mut result: Vec<usize> = vec![0;z*k];  
  let kk = if doubles.len() < k {
    doubles.len()
  } else {
    k
  };
  
  for i in 0..kk {
    for ii in 0..z {
      result[i*z+ii] = doubles[i] + zs[ii];
    }
  }
  result.sort();
  result.reverse();
  
  for i in 0..k {
    println!("{}", result[i]);
  }
}

Measured memory_bytes: 43512
def dfs(s):
    global ans
    if len(s) == n:
        cnt = 0
        for i in range(q):
            if s[abcd[i][1]-1]-s[abcd[i][0]-1] == abcd[i][2]:
                cnt += abcd[i][3]
        ans = max(ans, cnt)
        return
    last = 1
    if len(s) > 0:
        last = s[-1]
    for i in range(last, m+1):
        dfs(s+[i])
    return

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]
ans = 0
dfs([])
print(ans)

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

int main(){
  
  int X,A,N,L;
  int result=0;
  int flag=1;

  cin >> N >> L;

  



  for(int i=0; i < N; i++){
     result += L+i;
  }
  if((L > 0)&&(N+L >= 0)){
    result -= L;
  }
  if((L > 0)&&(N+L <= 0)){
    
  }
  if((L < 0)&&(N+L >= 0)){
    
  }
  if((L < 0)&&(N+L <= 0)){
    result -= (L+N-1);
  }


  cout << result << endl;
  return(0);
}


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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int tot = 0, totB = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'a') {
			if (tot < A + B) {
				cout << "Yes" << endl;
				tot++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (tot < A + B && totB < B) {
				tot++;
				totB++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
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;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string ans = "";
    REP(i, 0, N) {
        ans += S.substr(i, 1);
        ans += T.substr(i, 1);
    }
    cout << ans << endl;
}


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

string s;

int main() {
	cin >> s;

	bool flag = false;
	for (int i = 0; i < s.length() - 1; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C')flag = true;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)

int main(){
  string s;
  cin>>s;
  
  set <char> con;
  F(i,0,2) con.insert(s[i]);
  if(con.size()>1) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,n,s1,s2,c1,c2;
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=s1=s2=0;i<n;i++){
      scanf("%d %d",&c1,&c2);
      if(c1>c2) s1+=c1+c2;
      else if(c1<c2) s2+=c1+c2;
      else{ s1+=c1; s2+=c2; }
    }
    printf("%d %d\n",s1,s2);
  }while(1);
  return 0;
}

Measured memory_bytes: 0