akhauriyash/Code-Regression huggingface dataset:
N = int(input())

if N <= 9:
    print(N)
elif N <= 99:
    print(9)
elif N <= 999:
    print(9 + N - 99)
elif N <= 9999:
    print(909)
elif N<= 99999:
    print(909 + N - 9999)
else:
    print(90909)


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

int main(){
  int N;
  int A,B,C,D;
  
  cin>>N;
  
  A = N / 1000;
  B = N / 100 - A * 10;
  C = N / 10 - A * 100 - B * 10;
  D = N % 10;
  
  if((A==B && A==C)||(B==C && B==D)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){
    long long int n,ans=0,sum=0;
    cin>>n;
    vector<long long int>a(10000000);
    vector<long long int>b(10000000);
    for(int i=0;i<n+1;i++){
        cin>>a[i];
    }
    for(int i=0;i<n+1;i++){
        ans+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            a[i]=a[i]-b[i];
        }
        else if(a[i]+a[i+1]>=b[i]){
            a[i+1]=a[i+1]-b[i]+a[i];
            a[i]=0;
        }
        else{
            a[i]=0;
            a[i+1]=0;
        }
    }
    for(int i=0;i<n+1;i++){
        sum+=a[i];
    }
    ans=ans-sum;
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 156544
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   string s;
   cin>>s;
   vector<int>r,g,b;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='R')
        r.pb(i);
       if(s[i]=='G')
        g.pb(i);
       if(s[i]=='B')
        b.pb(i);
   }
   int ans=0;
   for(int i=0;i<s.length()-2;i++)
   {   char x=s[i];
       int j;
       vector<int>v;
       for(j=i+1;j<n-1;j++)
       {
           if(s[j]!=x)
            v.pb(j);
       }

       for(int k=0;k<v.size();k++)
       {   int l=v[k];
           if((s[i]=='R' && s[l]=='B') || (s[i]=='B' && s[l]=='R'))
       {
           int diff=l-i;
           if(l+diff<n)
           {
               if(s[l+diff]=='G')ans--;
           }
           ans+=(g.size()-(upper_bound(all(g),(l))-g.begin()));
       }
       else if((s[i]=='G' && s[l]=='R') || (s[i]=='R' && s[l]=='G'))
       {
           int diff=l-i;
           //debug(i,l);
           if(l+diff<n)
           {
               if(s[l+diff]=='B')ans--;
           }
           ans+=(b.size()-(upper_bound(all(b),(l))-b.begin()));
           //debug(ans);
       }
       else if((s[i]=='G' && s[l]=='B') || (s[i]=='B' && s[l]=='G'))
       {
           int diff=l-i;
           if(l+diff<n)
           {
               if(s[l+diff]=='R')ans--;
           }
           ans+=(r.size()-(upper_bound(all(r),l)-r.begin()));
       }
       }

   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>

using namespace std;

int main() {

	vector<vector<int>> path;
	path = vector<vector<int>>(4, vector<int>(4, 0));

	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		path[a][b]++;
		path[b][a]++;
	}

	vector<int> v;
	for (int i = 0; i < 4; i++) {
		v.push_back(i);
	}

	bool flag = false;

	do {
		for (int i = 0; i < 3; i++) {
			if (path[v[i]][v[i + 1]] != 1) {
				break;
			}
			if (i == 2)
				flag = true;
		}
	} while (next_permutation(v.begin(), v.end()));

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			else{
				calc(n, m);
			}
		}
	}
	public void calc(int n, int m){
		Node root = new Node("", null);

		for(int i = 0; i < n; i++){
			String line = sc.next();
			String[] lines = line.split("/");
			Node node = root;
			for(int t = 0; t < lines.length-1; t++){
				if(node.map.containsKey(lines[t])){
					node = node.map.get(lines[t]);
				}
				else{
					node.map.put(lines[t], new Node(lines[t], node));
					node = node.map.get(lines[t]);
				}
			}
			node.filenameMap.put(lines[lines.length-1], lines[lines.length-1]);
		}

		for(int i = 0; i < m; i++){
			String html1 = sc.next();
			String html2 = sc.next();

			if(html1.charAt(html1.length()-1) == '/') html1 += " ";
			if(html2.charAt(html2.length()-1) == '/') html2 += " ";
			
			String[] h1 = html1.split("/");
			String[] h2 = html2.split("/");

			String node1 = getNode(h1, root);
			String node2 = getNode(h2, root);

			if(node1 == null || node2 == null) System.out.println("not found");
			else if(node1 == node2)
				System.out.println("yes");
			else System.out.println("no");
		}
	}
	public String getNode(String[] html, Node root){
		Node node = root;
		for(int i = 0; i < html.length; i++){
			String s = html[i];
			if(s.equals(".")){
				continue;
			}
			else if(s.equals("..")){
				node = node.ue;
			}
			else if(i == html.length - 1 && s.equals(" ")){
				break;
			}
			else if(node.map.containsKey(s)){
				node = node.map.get(s);
			}
			else if(i == html.length - 1 && node.filenameMap.containsKey(s)){
				return node.filenameMap.get(s);
			}
			else return null;
		}
		if(node.filenameMap.containsKey("index.html")){
			return node.filenameMap.get("index.html");
		}
		else return null;
	}

	public static void main(String[] args){
		String[] t = "/home/ACM/index.html/".split("/");
		new Main().run();
	}
}

class Node{
	String name;
	HashMap<String, Node> map;
	HashMap<String, String> filenameMap;
	Node ue;

	Node(String n, Node ue){
		this.name = n;
		this.map = new HashMap<String, Node>();
		this.filenameMap = new HashMap<String, String>();
		this.ue = ue;
	}
}

Measured memory_bytes: 19664
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    int n, l;
    string s[10101];
    cin >> n >> l;
    for (int j = 0; j < n; ++j) {
        cin >> s[j];
    }

    sort(s, s + n);
    for (int j = 0; j < n; ++j) {
        cout << s[j] ;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll a,b; cin>>a>>b;
	cout<<a*b;
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,m,c, cnt = 0;
	cin >>n >> m >> c;
  	vector<int> b(m);
  	rep(i, m){
      	cin >> b[i];
	}
	rep(i, n){
      	int a,t=0;
      	rep(j, m) {
			cin >> a;
          	t += a*b[j];
        }
      	t += c;
      	if(t > 0)
        	cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{
    int F[100], n, x;
    x = 0;
    F[0] = 0;
    F[1] = 1;
    
    for (n = 2; n < 46; n++){
        F[n] = F[n-2] + F[n-1];
    }
    scanf("%d", &n);
    printf("%d\n", F[n+1]);
    
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){

    string s;

    cin >> s;

    if ((s[2] == s[3]) && (s[4] == s[5])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int x = 0;
    int N;
    string S;
    cin >> N >> S;
    vector<int> tem(N, 0);
    for (int i = 0; i < N; i++){
        if (S[i] == 'I') x++;
        else x--;
        tem[i] = x;
    }
    x = *max_element(tem.begin(), tem.end() );
    cout << (x>0?x:0);
}

Measured memory_bytes: 256
# dp[i] := i 項目以降を見たときの場合の数
#       = dp[i+1] + (Σ_{3<=d<=N-1} dp[i+d]) + (n-1)**2

# i 項目と i+1 項目について、
#   (1) i 項目が 1 の場合
#   (2) i 項目が 1 で無く、i+1 項目が 1 の場合
#   (3) i 項目も i+1 項目も 1 で無い場合
# で場合分けしてそれぞれを足している
# これを累積和で高速化する

# 初期化がややこしい

N = int(input())
mod = 10**9+7
dp = [N] * (N+1)
dp[N-1] = N
dp[N-2] = N*N
c = N * (N+1) + N-1
const = (N-1)**2
for i in range(N-3, -1, -1):
    ans = c - dp[i+2] + const
    dp[i] = ans
    c = (c + ans - 1) % mod
print(dp[0]%mod)


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}



int check(int n) {

	int temp = n + 9;

	temp = temp / 10;
	return temp * 10;



}

bool comp(pair<string,pair<int,int>> a , pair<string,pair<int,int>> b) {


	// return a % 10 > b % 10;
	if(a.F!=b.F)
		return a.F<b.F;
	return a.S.F>b.S.F;

}

int main() {
	int i, n, m, k, c = 0;
	c_p_c();
	cin>>n;
	string s[n];
	vector<pair<string , pair<int,int> >> p;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>s[i]>>k;
		p.push_back(make_pair(s[i],make_pair(k,i+1)));
	}


	sort(all(p),comp);



	for (int i = 0; i < n; ++i)
	{
		/* code */
		// cout<<p[i].F<<" : "<<p[i].S.F<<endl;
		cout<<p[i].S.S<<endl;
	}


	// for (int i = 0; i < n; ++i)
	// {
	// 	string str = s[i];



	// 	for (int j = 0; j < p.size(); ++j)
	// 	{
	// 		/* code */
	// 		if(str==p.F)
	// 	}
	// }
	return 0;
}



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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  set <int> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (!s.count(x)) s.insert(x);
    else s.erase(x);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4992
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
        # グループの数を記憶しておく
        self.root_num=n

    def Tree_num(self):
        return self.root_num
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
            self.root_num-=1

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            self.root_num-=1
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M=na()
UF = UnionFind(N)
for i in range(M):
    x,y,z=na()
    UF.Unite(x,y)

print(UF.Tree_num())


Measured memory_bytes: 7748
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public void Calc()
        {

            var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var N = p[0];
            var M = p[1];
            var Q = p[2];

            var As = new int[Q, 4];
            foreach (var i in Enumerable.Range(0, Q))
            {
                var p2 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                
                foreach(var j in Enumerable.Range(0, 4))
                {
                    As[i, j] = p2[j];
                }
            }
            var nums = Enumerable.Range(1, M).ToArray();
            var combis = Combination.Enumerate<int>(nums, N);

            long ans = 0;
            foreach (var combi in combis)
            {
                long sum = 0;
                foreach (var i in Enumerable.Range(0, Q))
                {
                    if (combi[As[i, 1]-1] - combi[As[i, 0]-1] == As[i, 2])
                    {
                        sum += As[i, 3];
                    }
                }
                ans = Math.Max(sum, ans);
            }
            Console.WriteLine(ans);

        }


    }
    public static class Combination
    {
        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition = false)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };

                // item よりも前のものを除く （順列と組み合わせの違い)
                // 重複を許さないので、unusedから item そのものも取り除く
                var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).ToList();

                foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}


Measured memory_bytes: 41552
import sys
input=sys.stdin.readline
n=int(input())
h_list=list(map(int,input().split()))
ans=0
count=0
for i in range(1,n):
    if h_list[i]<=h_list[i-1]:
        count+=1
    else:
        ans=max(ans,count)
        count=0
ans=max(ans,count)
print(ans)





Measured memory_bytes: 59632
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N,M;
	cin >> N >> M;
	int a,b,sai[Nmax]={};
	int ans=0;
	REP(i,M){
		cin >> a >> b;
		sai[b]=max(sai[b], a);
	}
	int broke=0;
	FOR(i,2,N+1){ //b=2から
		if(sai[i]==0) continue;
		if(sai[i] > broke){
			broke=i-1;
			ans++;
		}
	}	
  	cout <<ans<< endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	int n,a,b;
	long long int total=0;
	scanf("%d %d %d", &n, &a, &b);
	
	int i1=0,i2=0, i3=0, i4=0, i5=0;
	for(int i=1;i<=n;i++){
//		
//		i1=i/10000;	
//		i2=i/1000;
//		i3=(i%1000)/100;
//		i4=(i%100)/10;
//		i5=i%10;
		int temp=i;
		int sum=0;
		while(temp!=0){
			sum+= temp%10;
			temp/=10;
		}

		if(sum >=a && sum<=b){
			total+=i;
		
		}
	}

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


	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t P=1;
  int x = pow(10,9)+7;
  for(int i=0;i<N;i++){
    P *= (i+1);
    if(P>x){
      P=P%x;
    }
  }
  
  cout << P%x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] Ws = W.split(" ");
		int[] A = new int[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = (int)Long.parseLong(Ws[i]);
		}

		long ans = 0;
		for(int i=0;i<N;i++){
			if(i==A[A[i]-1]-1){
				ans++;
			}
		}

		System.out.println(ans/2);


	}
}


Measured memory_bytes: 35752
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    if(S=="Sunny")cout<<"Cloudy"<<endl;
    if(S=="Cloudy")cout<<"Rainy"<<endl;
    if(S=="Rainy")cout<<"Sunny"<<endl;
    return 0;
}

Measured memory_bytes: 764
using System;

class Tax{
  static void Main(){
    var input = Console.ReadLine().Split();
    var eight_tax = float.Parse(input[0]);
    var ten_tax = float.Parse(input[1]);
    float price = -1;
    
    for(float i=1;i<=1000;i++){
      if(Math.Floor(i*0.08) == eight_tax &&  Math.Floor(i*0.1) == ten_tax){
        price = i;
        break;
      }
    }
    Console.WriteLine(price);
  }
}
 

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
ll n;
vector<P> v;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    v.resize(n);
    rep(i,0,n){
        cin>>v[i].sc>>v[i].fr;
    }
    sor(v);
    ll now=0;
    rep(i,0,n){
        if(now+v[i].sc>v[i].fr){
            cout <<"No"<<"\n";
            return 0;
        }
        now+=v[i].sc;
    }
    cout <<"Yes"<<"\n";
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int now = 0;
    string T = "ATCG";

    for(int i = 0; i < s.size(); i++)
    {
      int now = 0;
        for(int j = i; j < s.size(); j++)
        {
          bool ok = false;
          for(int k = 0; k < 4; k++)
          {
            if(s[j] == T[k])
            {
              ok = true;
            }
          }
          if(ok){
                now++;
                ans = max(ans, now);
                }
            else{
                break;
                }
        }
    }
  cout << ans << endl;
  return 0;
}
         

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int M,D;
  cin>>M>>D;
  int count=0;
  
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      int d1=j%10;
      int d10=j/10;
      if(d1>=2){
        if(d10>=2){
          if(d1*d10==i){
            count++;
          }
        }
      }
    }
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a,b;
  cin>>a>>b;
  int sum=0;
  if(a==1)
 	sum+=300000;
  if(a==2)
    sum+=200000;
  if(a==3)
    sum+=100000;
   if(b==1)
 	sum+=300000;
  if(b==2)
    sum+=200000;
  if(b==3)
    sum+=100000;
  
 	if(a==1 && b==1)
      	sum+=400000;
  cout<<sum<<endl;
 	
 
     
     
     
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m, P;
const ll M = -4e18;
const ll MM = 4e18;
ll a[5005], b[5005], c[5005];
ll d[2505];

int main()
{
    scanf("%lld%lld%lld", &n, &m, &P);
    for(ll i = 0; i < m; i++)
    {
        scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
        c[i] -= P;
    }
    for(ll i = 1; i <= n; i++) d[i] = M;
    d[1] = 0;
    for(ll i = 0; i <= 2 * n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            if(d[a[j]] == M) continue;
            d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
        }
    }
    ll ans = d[n];
    for(ll i = 0; i <= 2 * n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            if(d[a[j]] == M) continue;
            ll t = d[b[j]];
            d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
            if(t < d[b[j]])
            {
                d[b[j]] = MM;
            }
        }
    }
    if(d[n] < MM) cout<<max(ans, 0LL)<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mp map<int,int>
using namespace std;
int main() {
	int a;
	cin>>a;
	cout<<3*a*a;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0){
			int n=sc.nextInt()-1;
			int h=sc.nextInt();
			int mc = 0;
			int mf = 0;

			while(n-->0){
				int nh = sc.nextInt();
				if(nh-h>mc)mc=nh-h;
				if(h-nh>mf)mf=h-nh;
				h=nh;
			}
			System.out.println(mc+" "+mf);
		}
	}
}

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


int main() {
  int a,b;
  cin >> a>>b;
  long ans=b;
  a--;
  while(a--){
    ans*=(b-1);
  }
    cout<<ans<<endl;
  
}





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

int main() {
  string S;
  int cnt=0;
  cin >> S;

  for(int i=0;i<3;i++){
   for(int j=0;j<3;j++){
    if(S[i]==S[j]){
     cnt++;
    }
   }
  }
  if(cnt ==3){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VLL = vector <long long>;
using VVLL = vector <VLL>;

int main() {
    long long N;
    long long X;
    int M;
    cin >> N >> X >> M;
    // Sigma A^0 + A^2 + A^4 + A^8 + A^16 + A^32 ...
    long long res = 0;
    long long fpr = X;
    VLL idx(M, -1);
    VLL val(M+1, -1);

    for (long long i = 0; i < N; ++i) {

        if (idx[fpr] != -1) {
            long long len = i - idx[fpr];
            long long sum = 0;

            for (int j = idx[fpr]; j < i; ++j) {
                sum += val[j];
            }

            long long remain = N - i;
            long long blks = remain/len;
            res += sum * blks;

            for (long long j = i+blks*len; j < N; ++j) {
                res += fpr;
                fpr = fpr*fpr%M;
            }

            break;
        }

        idx[fpr] = i;
        val[i] = fpr;
        res += fpr;
        fpr = fpr*fpr%M;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4840
N, M = gets.split.map(&:to_i)

@matrix = Array.new(N){[]}
@visit  = Array.new(N)
a = []
b = []

$<.each_with_index do |line, i|
  a[i], b[i] = line.split.map(&:to_i)
  a[i] -= 1
  b[i] -= 1
  @matrix[a[i]][b[i]] = @matrix[b[i]][a[i]] = true
end


def check(node)
  return if @visit[node]
  @visit[node] = true
  @matrix[node].each_with_index do |n, i|
    if n
      check(i)
    end
  end
end

count = 0

M.times do |t|
  @visit.fill(false)
  @matrix[a[t]][b[t]] = @matrix[b[t]][a[t]] = false

  check(0)
  count += 1 if !@visit.all?

  @matrix[a[t]][b[t]] = @matrix[b[t]][a[t]] = true
end

p count

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  int d=a/b;
  int r=a%b;
  double f=(double)a/(double)b;
  cout <<d<<" "<<r<<" "<<fixed<<setprecision(8)<<f<<endl;
  return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,h,w;
	cin>>h>>w;
	char a[h+2][w+2];
	for(i=0;i<=h+1;i++)
	  for(j=0;j<=w+1;j++)
	  {
	  	a[i][j]='.';
	  }
	for(i=1;i<=h;i++)
	  for(j=1;j<=w;j++)
	  {
	  	cin>>a[i][j];
	  }
	for(i=1;i<=h;i++)
	  for(j=1;j<=w;j++)
	  {
	  	if(a[i][j]=='#'&&a[i-1][j]!='#'&&a[i+1][j]!='#'&&a[i][j+1]!='#'&&a[i][j-1]!='#')
	  	{
	  		cout<<"No";
	  		return 0;
		}
	  }
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;main(){int n,l,a;cin>>n>>l;a=0;for(int i=0;i<n;i++)a+=l+i;if(l<=0&&0<=l+n-1)cout<<a;else if(0<l)cout<<a-l;else cout<<a-(l+n-1);}

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

ll N, M;
vector<ll> X;

int main() {
    scanf("%Ld %Ld", &N, &M);
    X.resize(M);
    for (int i = 0; i < M; i++) scanf("%Ld", & X[i]);
    sort(X.begin(), X.end());

    if (N >= M) {
        printf("0\n");
        return 0;
    }

    vector<long long> L;
    for (int i = 1; i < M; i++) L.push_back(X[i]-X[i-1]);
    sort(L.begin(), L.end(), greater<ll>());

    ll ans = X.back() - X[0];
    for (int i = 0; i < N-1; i++) ans -= L[i];

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

Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int a[30000000];
int f[50000000];
bool bad[50000000];

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

    for(int i=1;i<=m;i++)
        cin>>a[i];
    f[1] = 1;
    f[2] = 2;
    for(int i=1;i<=m;i++)
        bad[a[i]] = true;
    if(bad[1] == true)
    {
        f[1] = 0;
        f[2] = 1;
    }
    if(bad[2] == true)
        f[2] = 0;
    for(int i=3;i<=n;i++)
    {
        if(bad[i] == true)
            f[i] = 0;
        else
        {
            f[i] = f[i-1] + f[i-2];
            f[i] = f[i] % 1000000007;
        }
        
    }
    cout<<f[n]%1000000007;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double EPS = 1e-5;
const double PI=atan2(0,-1);

int main()
{
    string s;
    cin>>s;
    
    bool flag=0;
    queue<int> q;
    q.push(0);
    while(!q.empty())
    {
        int l=q.front();
        if(s.size()==l)
        {
            flag=1;
            break;
        }
        q.pop();
        if(s.substr(l,7)=="dreamer")
        {
            q.push(l+7);
        }
        if(s.substr(l,5)=="dream")
        {
            q.push(l+5);
        }
        if(s.substr(l,6)=="eraser")
        {
            q.push(l+6);
        }
        if(s.substr(l,5)=="erase")
        {
            q.push(l+5);
        }

    }

    if(flag)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int n,k;

//与えられたWに対して、各トラックの積載上限をｐとした時にすべて積み込めるかを判定する。できるのなら１を、できないのなら０を返す。
int judge(int *W,int p){
  int i;
  int num=1;
  int judge=0;
  for(i=0;i<n;i++){
    if(judge + W[i] >p){
      if(judge==0) return 0;
      num+=1;
      if(num>k) return 0;
      i-=1;
      judge=0;
    }
    else judge+=W[i];
  }
  return 1;
}




int main(){
  int *W;
  int i,j;
  int max=0;

  scanf("%d%d",&n,&k);
  W=malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%*[ \n]%d",&W[i]);
    if(W[i] > max) max=W[i];
  }
 
  int a,b,p;
  a=max;
  b=n*max;

  while(1){
    if(a==b) break;
    p=(a+b)/2;
    if(judge(W,p)==1) b=p;
    if(judge(W,p)==0) a=p+1;   
  }//pの最適値の下限をaが、上限をbが与える。aとbを二分探索で更新していく。

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


   
  


Measured memory_bytes: 2248
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<char, int> mp;
    for (int i = 0; i < n; i++)
    {
        char c;
        cin >> c;
        mp[c]++;
    }
    cout << (mp.size() == 3 ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    y = -y
    b = [x,y,i+1]
    a.append(b)
ans = sorted(a, key=lambda x:(x[0],x[1]))
for i in range(n):
    print(ans[i][2])

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

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

int main(){
    int n;cin>>n;
    vector<int >a(n);
    vector<int>b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    vector<P>p(n);
    rep(i,n){
        p[i]=make_pair(b[i],a[i]);

    }
    sort(p.begin(),p.end());
    ll sum = 0;
    rep(i,n){
        sum+=p[i].second;
        if(sum>p[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 6416
A, B = map(int, input().split())

if(B<22):
    print("0")
else:
    answer=0
    for i in range(22,B+1):
        if(i%10 != 1 and i%10 != 0):
            if((i//10) * (i%10) <= A):
                answer+=1
    print(answer)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

signed main(){
	int N, i, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	int *inv = (int *)malloc(sizeof(int) * (N + 1));
	int *inv_sum = (int *)malloc(sizeof(int) * (N + 1));
	inv[1] = 1;
	for(i = 2; i <= N; i++){
		inv[i] = MOD(-(p / i) * inv[p % i]);
	}
	inv_sum[0] = 0;
	for(i = 1; i <= N; i++){
		inv_sum[i] = MOD(inv_sum[i - 1] + inv[i]);
	}
	for(i = 0; i < N; i++){
		ans = MOD(ans + (inv_sum[i + 1] + inv_sum[N - i] - 1) * A[i]);
	}
	for(i = 1; i <= N; i++){
		ans = MOD(ans * i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
n=gets.to_i
a=gets.split.map(&:to_i)
a.unshift(0)
a.push(0)
sum=0
for i in 1..(n+1)
    sum+=(a[i]-a[i-1]).abs
end

for i in 1..n
    puts sum-(a[i]-a[i-1]).abs-(a[i+1]-a[i]).abs+(a[i+1]-a[i-1]).abs
end


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

int main(void) {
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == '1')
			++ans;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

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

  ll v=0;
  while(n>0){
    n/=k;
    v++;
  }
  cout<<v<<endl;
  
  return 0;
}


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

int main(){
  int n, count, max;
  int h[150];
  cin >> n;
  for (int i = 0; i < n; i++){
  cin >> h[i];
  }
  count = 0;
  max = -100;
  for (int j = 0; j < n; j++){
  if (h[j] >= max){
    max = h[j];
  count++;
  }else{
  continue;
  }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y){}

	Point operator + (Point p){ return Point(x + p.x, y + p.y); }
	Point operator - (Point p){ return Point(x - p.x, y - p.y); }
	Point operator * (Point p){ return Point(x * p.x, y * p.y); }
	Point operator / (Point p){ return Point(x / p.x, y / p.y); }

	Point operator * (double t){ return Point(x * t, y * t); }
	Point operator / (double t){ return Point(x / t, y / t); }


	double abs(){ return sqrt(norm()); }
	double norm(){ return x * x + y * y; }

	bool operator<(const Point &p){ return (x != p.x) ? (x < p.x) : (y < p.y); }
	bool operator==(const Point &p)
	{
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;

class Segment{
public:
	Point p1, p2;
};

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1 - a2, b1 - b2);
}

Point projection(Segment s, Point p){
	Vector v1 = s.p2 - s.p1;
	Vector v2 = p - s.p1;
	return s.p1 + v1 * dot(v1, v2) / v1.norm();
}

Point reflection(Segment s, Point p){
	return p + (projection(s, p) - p) * 2.0;
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	cout.precision(20);

	Segment s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;


	int q; cin >> q;
	for (int i = 0; i < q; ++i){
		Point p; cin >> p.x >> p.y;
		Point res = reflection(s, p);
		cout << res.x << " " << res.y << endl;
	}
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int p[31]={};
int ans_p[31]={0,1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};
int ret=8;

void a(){
  swap(p[1],p[28]);
  swap(p[2],p[29]);
  swap(p[3],p[30]);
  swap(p[15],p[16]);
  swap(p[21],p[19]);
}

void b(){
  swap(p[3],p[22]);
  swap(p[6],p[25]);
  swap(p[9],p[28]);
  swap(p[19],p[12]);
  swap(p[13],p[15]);
}

void c(){
  swap(p[7],p[22]);
  swap(p[8],p[23]);
  swap(p[9],p[24]);
  swap(p[18],p[13]);
  swap(p[10],p[12]);
}

void d(){
  swap(p[1],p[24]);
  swap(p[4],p[27]);
  swap(p[7],p[30]);
  swap(p[21],p[10]);
  swap(p[16],p[18]);
}

void f(int k){
  int cnt=0;
  for(int i=1;i<31;i++){
    if( p[i]==ans_p[i]) cnt++;
  }
  if(cnt==30) {
    ret=min(ret, k);
  }
  if(ret<=k) return;
  a(); f(k+1); a();
  if(ret<=k) return;
  b(); f(k+1); b();
  if(ret<=k) return;
  c(); f(k+1); c();
  if(ret<=k) return;
  d(); f(k+1); d();
  if(ret<=k) return;
}


int main(){

  int n;
  cin>> n;
  for(int i=0;i<n;i++){
    for(int j=1;j<31;j++){
      cin>> p[j];
    }
    ret=8;
    f(0);
    cout<< ret<< endl;
  }

}

Measured memory_bytes: 1160
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
    int ca,ab,bc;
    cin>>ab>>bc>>ca;
    int ans;
    ans=ab*bc/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N= int(input())
E = [input().split()[2:] for _ in range(N)]
Q = [0]
L = [0] + [-1]*N
frag = [1] + [0]*N
def func(ide):
    global Q
    for i in E[ide]:
        i = int(i) - 1
        if frag[i] != 1:frag[i] = 1;L[i] = L[ide] +1 ;Q.append(i)
    

while Q:top = Q[0];func(top);del Q[0]

for i in range(N):print(i + 1 ,int(L[i]))



Measured memory_bytes: 5628
while True:
    try:
        n = int(input())
        if n > 2000:
            n = 4000 - n

        ans = (n+1)*(n+2)*(n+3)/6
        if n >= 1001:
            n = n - 1001
            ans = ans - 2*(n+1)*(n+2)*(n+3)/3

        print(int(ans))

    except EOFError:
        break


Measured memory_bytes: 5592
#include<stdio.h>
int main() { 
	long long l,r;
	scanf("%lld%lld",&l,&r);
	r=(r>l+2019)?l+2019:r;
	long long ans=2019;
	for(long long i=l;i<=r;i++)
		for(long long j=i+1;j<=r;j++)
			ans=(ans>(i*j)%2019)?(i*j)%2019:ans;
	printf("%lld",ans);
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 2092
#include <cstdio>
#include <algorithm>

using namespace std;

int mod = 1000000007;
long long a[1000001];
long long inv[1000001];
long long fact[1000001];
long long invfact[1000001];

void calc_inv(int n, int mod) {
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

long long comb(int x, int y, int mod) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}

int main() {
    int n, m, k, l = 0, r = 0, i;
    long long ans = 0, sum = 1;
    
    scanf("%d %d %d", &n, &m, &k);
    
    calc_inv(1000000, mod);
    
    a[0] = 1;
    for (i = 1; i <= 1000000; i++) a[i] = a[i - 1] * 3 % mod;
    
    for (i = 0; i <= m + k; i++) {
        ans += a[m + k - i] * comb(n + i - 1, n - 1, mod) % mod * sum % mod;
        
        sum = sum * 2 % mod;
        if (l > 0) sum = (sum + comb(i, l - 1, mod)) % mod;
        if (r < i) sum = (sum + comb(i, r + 1, mod)) % mod;
        
        r++;
        
        if (i + 1 - l > k) {
            sum = (sum - comb(i + 1, l, mod) + mod) % mod;
            l++;
        }
        
        if (r > m) {
            sum = (sum - comb(i + 1, r, mod) + mod) % mod;
            r--;
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m, q;
  cin >> n >> m >> q;

  vector<pair<ll, ll>> train(m);
  rep(i, m) { cin >> train[i].first >> train[i].second; }

  vector<pair<ll, ll>> question(q);
  rep(i, q) { cin >> question[i].first >> question[i].second; }

  ll tm[510][510] = {};
  FORm(itr, train) { tm[itr->first][itr->second]++; }

  // i駅を出発地してk駅以前までを終点とする電車の数
  rep(i, n + 1) {
    REP(k, n + 1) { tm[i][k] += tm[i][k - 1]; }
  }

  for (ll i = n; i >= 0; i--) {
    rep(k, n + 1) { tm[i][k] += tm[i + 1][k]; }
  }

  FORm(itr, question) { cout << tm[itr->first][itr->second] << endl; }

  return 0;
}


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

using namespace std;

const int maxn = 2e3 + 5;

int a[maxn];

int main() {
	int n;
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 0 ; i < n ; i++) {
		cin >> a[i];
	}
	sort(a , a + n);
	long long ans = 0;
	for(int i = 0 ; i < n -2; i++) {
		for(int j = i + 1 ; j < n - 1; j++) {
			int t = a[i] + a[j];
			int left = j + 1, right = n - 1;
			if(a[j + 1] >= t) {
				continue;
			}
			while(left < right) {
				int mid = (left + right + 1) / 2;
				if(a[mid] < t)left = mid;
				else right = mid - 1;
			}
			//cout << "i = " << i <<" j = " << j <<" left = " << left << "\n";
			if(left > j) 
			ans += left - j;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define itn int
vector<int> dp(100005,-1);
vector<int> e[100005];

int f(int g){
  if(dp[g]!=-1) return dp[g];
  int nx=0;
  for(int j=0;j<e[g].size();j++){
    nx=max(nx,f(e[g][j])+1);
  }
  dp[g]=nx;
  return nx;
}
signed main(){
  int a,b,c,d,n=0;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c>>d;
    e[c].push_back(d);
  }
  for(int i=1;i<=a;i++){
    n=max(n,f(i));
  }
  cout<<n<<"\n";
  return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
int main(void){
    // Here your code !
    int i,k;
    
    for(i = 1;i <= 9;i++)
    {
        for(k = 1;k <= 9;k++)
        {
            printf("%dx%d=%d\n",i,k,i*k);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const ll MOD = 998244353;
const int N = 200000 + 5;
ll dp[N], sum[N];

int main() {
    int n, k;
    cin >> n >> k;
    vector<pii> rng(k);
    for (int i = 0; i < k; ++i) {
        cin >> rng[i].first >> rng[i].second;
    }
    dp[1] = sum[1] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 0; j < k; ++j) {
            int l, r;
            tie(l, r) = rng[j];
            dp[i] = (dp[i] + sum[max(0, i - l)] - sum[max(0, i - r - 1)] + MOD) % MOD;
        }
        sum[i] = (dp[i] + sum[i - 1]) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6284