akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const string wa="UNRESTORABLE";
string s,t,a;
vector<string>v;
int main()
{
	cin>>s>>t;
	a=s;
	for(int i=0;i+t.size()<=s.size();i++)
	{
		string ss=s.substr(i,t.size());
		int j;
		for(j=0;j<t.size();j++)
		{
			if(s[i+j]==t[j] || s[i+j]=='?')
			{
				continue;
			}
			break;
		}
		if(j!=t.size())
		{
			continue;
		}
		for(j=0;j<t.size();j++)
		{
			s[i+j]=t[j];
		}
		for(j=0;j<s.size();j++)
		{
			if(s[j]=='?')
			{
				s[j]='a';
			}
		}
		v.push_back(s);
		s=a;
	}
	sort(v.begin(),v.end());
	if(v.size()==0)
	{
		cout<<wa<<endl;
	}
	else
	{
		cout<<v[0]<<endl;
	}
	return 0;
}


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


#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); ++i)



int main(void){
    int N;
    cin >> N;
    unordered_set<int> A(N);
    rep(i, N){
        int m;
        cin >> m; 
        A.insert(m);
    }
    
    int cnt = 0;
    int Q;
    cin >> Q;
    rep(i, Q){
        int m;
        cin >> m;
        cnt += A.count(m);
    }
    
    cout << cnt << endl;
    
    return 0;
}


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt(), cnt = 0;
		int[] S = new int[n];
		for(int i = 0; i < n; ++i)
			S[i] = sc.nextInt();
		int q = sc.nextInt();
		for(int i = 0; i < q; ++i){
			int t = sc.nextInt();
			if(linearSearch(S, t)) ++cnt;
		}
		System.out.println(cnt);
	}
	
	static boolean linearSearch(int[] v, int key){
		int n = v.length;
		if(key == v[n-1]) return true;
		int tmp = v[n-1]; v[n-1] = key;
		int i = 0;
		while(v[i] != key) ++i;
		v[n-1] = tmp;
		if(i < n-1) return true;
		return false;
	}

}


class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 26804
import java.util.Arrays;
import java.util.Scanner;

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


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    if(s=="Sunny")
        cout << "Cloudy";
    else if(s=="Cloudy")
        cout << "Rainy";
    else
        cout << "Sunny";
}


Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll A,B,C,X,Y;


int main() {
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    if (C*2 <= A+B){
        ll t = min(X,Y);
        X -= t;
        Y -= t;
        ans += C*2*t;
        if (X > 0){
            if (C*2 <= A){
                ans += C*2*X;
            }
            else{
                ans += A*X;
            }
        }
        else{
            if (C*2 <= B){
                ans += C*2*Y;
            }
            else{
                ans += B*Y;
            }
        }
    }
    else{
        ll t = min(X,Y);
        X -= t;
        Y -= t;
        ans += (A+B)*t;
        if(X > 0) ans += A*X;
        else ans += B*Y;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
MOD = 10**9+7
table = [0]*(N+1)
table[0] = 1
broken = [1]*(N+1)
for a in A:
    broken[a] = 0

for i in range(N+1):
    if i+1<=N and broken[i+1]:
        table[i+1] += table[i]
    if i+2<=N and broken[i+2]:
        table[i+2] += table[i]

print(table[N]%MOD)

Measured memory_bytes: 463476
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        getline(cin, s);
        if(s.size() == 0)
            return 0;

        int n = s.size();
        string ret;
        for(int i=0; i<n; ++i){
            if(s[i] == '@'){
                ret += string(s[i+1]-'0', s[i+2]);
                i += 2;
            }else{
                ret += s[i];
            }
        }
        cout << ret << endl;
    }
}

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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	sort(a.rbegin(), a.rend());
	double whole = accumulate(a.begin(), a.end(), 0ll);
	ll min_pop = *(a.begin() + m - 1);
	if (min_pop < whole / (4 * m))cout << "No" << endl;
	else cout << "Yes" << endl;
}

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



/* Name of the class has to be "Main" only if the class is public. */



public class Main
{
     
     
     static int mod(int a, int m) 
{ 
    return (a%m + m) % m; 
}
   
    
public static void main (String[] args) throws java.lang.Exception
{Scanner scn = new Scanner(System.in) ;

int n = scn.nextInt() ;

int ans  = (n) + (n *n) + (n*n*n) ;

System.out.println(ans) ;

              
}
}




              
             

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

public class Main {

    static long mod = (long) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        int n = s.length();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = s.charAt(i) - '0';
        }
        int d = in.nextInt();
        long[][][] dp = new long[n][d][2];
        int dig0 = num[0];
        dp[0][dig0 % d][0] = 1;
        for (int i = 0; i < 10; i++) {
            if (i < dig0)
                dp[0][i % d][1] += 1;
        }
        int last = dig0 % d;
        for (int i = 1; i < n; i++) {
            int dig = num[i];
            dp[i][(last + dig) % d][0] = (dp[i][(last + dig) % d][0] + dp[i - 1][last][0]) % mod;
            last = (last + dig) % d;
            for (int j = 0; j < d; j++) {
                for (int l = 0; l < 10; l++) {
                    dp[i][(j + l) % d][1] = (dp[i][(j + l) % d][1] + dp[i - 1][j][1]) % mod;
                    if (l < dig)
                        dp[i][(j + l) % d][1] = (dp[i][(j + l) % d][1] + dp[i - 1][j][0]) % mod;
                }
            }
        }
        long ans = (dp[n - 1][0][0] + dp[n - 1][0][1]) % mod;
        out.println(((ans - 1) + mod) % mod);
        out.close();
    }

    static long[][] powMat(long[][] a, long pow) {
        if (pow == 1) {
            return a;
        } else {
            if (pow % 2 == 0) {
                return powMat(mul(a, a), pow / 2);
            } else {
                return mul(a, powMat(mul(a, a), pow / 2));
            }
        }
    }

    static long[][] mul(long[][] a, long[][] b) {
        int n = a.length;
        long[][] c = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][k] = (c[i][k] + (a[i][j] * b[j][k]) % mod) % mod;
                }
            }
        }
        return c;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 88876
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main() {
    string str = chomp(readln());
    long n = to!long(str);
    writeln(factrial(n));
}

long factrial(long n) {
    if (n == 0) {
        return 1;
    } else {
        return n * factrial(n-1);
    }
}

Measured memory_bytes: 1040
#include <stdio.h>
int main()
{
    int i;
    char line[1100];
    fgets(line,sizeof(line),stdin);
    for(i = 0; line[i+4] != 0; i++){
            if(line[i] == 'a' && line[i+1] == 'p' && line[i+2] == 'p' && line[i+3] == 'l' && line[i+4] == 'e') {
                    line[i] = 'p'; line[i+1] = 'e'; line[i+2] = 'a'; line[i+3] = 'c'; line[i+4] = 'h';
                    continue;
            }
            if(line[i] == 'p' && line[i+1] == 'e' && line[i+2] == 'a' && line[i+3] == 'c' && line[i+4] == 'h') {
                    line[i] = 'a'; line[i+1] = 'p'; line[i+2] = 'p'; line[i+3] = 'l'; line[i+4] = 'e';
            }
    }
    printf("%s",line);
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI X(N); REP(i, N) cin >> X[i];

    LL ans = LLINF;
    FOR(i, 1, 101) {
        LL pre = 0;
        REP(j, N) {
            pre += (X[j] - i) * (X[j] - i);
        }
        chmin(ans, pre);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int K,T;
  cin >> K >> T;
  vector<int> a(T);
  rep(i,0,T - 1) cin >> a[i];
  sort(all(a));
  cout << max(a[T - 1] + a[T - 1] - K - 1,0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string lcs(string text1, string text2) {
        vector<vector<int>> dp(text1.size()+1,vector<int>(text2.size()+1,0));
        for(int i=1;i<dp.size();i++){
            for(int j=1;j<dp[1].size();j++){
                if(text1[i-1]==text2[j-1]){
                    dp[i][j]= 1+ dp[i-1][j-1];//just before consderng t1[i] & t2[j] lcs length was dp[i-1][j-1;]
                }
                else
                    dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
            }
        }
        //printing lcs;
        int i=dp.size()-1, j=dp[0].size()-1;
        string ans="";
        while(1){
            if(i<1||j<1) break;
            if(dp[i][j-1]==dp[i][j]){
                --j;
                continue;
            } 
            else if(dp[i-1][j]==dp[i][j] ){ 
                --i;
                continue;
            }
            else if( text1[i-1]==text2[j-1] && dp[i][j]==dp[i-1][j-1]+1){
                ans=text1[i-1]+ans;
                --i;--j;
            }           
            // if(dp[i][j]==0)
            //     break;
        }
        // reverse(ans.begin(),ans.end());
        return ans;
    }
    
    int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    cout<<lcs(s,t);
}

Measured memory_bytes: 35584
package main

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

const Mod = int(1e9) + 7

func main() {
	N, K := nextInt(), nextInt()
	As := nextInts(N)

	inversions := 0
	downers := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			if As[i] > As[j] {
				downers++
				if i < j {
					inversions++
				}
			}
		}
	}

	sum1 := (inversions * K) % Mod
	sum2 := downers * ((K * (K - 1) / 2) % Mod)
	fmt.Println((sum1 + sum2) % Mod)
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		str = str.replace("BC", "D");
		String array[] = str.split("B|C");
		long ans = 0;
		for(int i = 0; i < array.length; i ++) {
			if(array[i].length() > 0) {
				int tmp = 0;
				for(int j = array[i].length() - 1; j >= 0; j --) {
					char c = array[i].charAt(j);
					if(c == 'D') {
						tmp ++;
					}else if(c == 'A') {
						ans += tmp;
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34052
#include <stdio.h>
int main(void)
{
	int n,i,f[45];
	
	scanf("%d",&n);
	
	f[0]=1; f[1]=1;
		for (i=2;i<=n;i++){
			f[i]=f[i-2]+f[i-1];
		}
	printf("%d\n",f[n]);
	
	return 0;
}

Measured memory_bytes: 1820
n = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while True:
    for i in range(n):
        if A[i] % 2 != 0:
            flag = False        
    if flag == False:
        break
    for i in range(n):
        A[i] /= 2
    count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  int R, G, B, N;
  long long ret = 0;
  cin >> R >> G >> B >> N;
  for (int r=0; r<=N / R; r++){
    for (int g=0; g<=(N - R*r) / G; g++){
      if ((N - r*R - g*G) % B == 0) ret++;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const int MAX_V = 26;
set<int> to[MAX_V], from[MAX_V];
int main(){
    string S, T; cin >> S >> T;
    int n = S.size();
    rep(i, n){
        int s = S[i] - 'a';
        int t = T[i] - 'a';
        to[s].insert(t);
        from[t].insert(s);
    }
    rep(i, 26){
        if(to[i].size() >= 2 || from[i].size() >= 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

public class Main {

 public static void main(String[] args){
       InputStream in = System.in;
       Scanner sc = new Scanner(in);
       
       int K = sc.nextInt();
       int S = sc.nextInt();
       
       int num = 0;
       
       for (int i = 0; i <= K; i++){
       for (int j= 0; j <= K; j++){
      int z = S - i - j;
      if(z >= 0 && z <= K){
      num++;
      }
       } 
       }
       
       
       System.out.println(num);
       
 }

}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define ll long long
#define db double
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define inf LONG_LONG_MAX
#define inf1 INT_MAX
using namespace std;
/*
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%mod;
    if(b%2)
        return (a*temp)%mod;
    return temp;
}

ll _pow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=_pow(a,b/2);
    temp=(temp*temp);
    if(b%2)
        return (a*temp);
    return temp;
}

ll mod_in(ll n){
    return mpow(n,mod-2);
}
*/
int main()
{
    fastio
    ll n, a, b;
    cin>>n>>a>>b;
    ll ans=0;
    ans=a*(n/(a+b));
    ll d=n%(a+b);
    ans+=min(d, a);
    cout<<ans;
    return 0;
}

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


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

  int count = 0;

  for(int i=0; i<3; i++){
    if(s.at(i) == t.at(i)){
      count += 1;
    }
  }

  cout << count << endl;

  
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a + b)%2 != 0 ){
  cout << (a + b) / 2 + 1 << endl; 
  }
  else {
  cout << (a + b) / 2 << endl;
  }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    string s; cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R' && s[i + 1] == 'R' && s[i + 2] == 'R'){
            cout << 3 << endl;
            return 0;
        }
        if(s[i] == 'R' && s[i + 1] == 'R'){
            cout << 2 << endl;
            return 0;
        }
        if(s[i] == 'R'){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>

int main(){

	double a, b;
	while (std::cin >> a >> b){

		if (a < 35.5&&b < 71.0){
			std::cout << "AAA" << std::endl;
		}
		else if (a < 37.5&&b < 77.0){
			std::cout << "AA" << std::endl;
		}
		else if (a < 40.0&&b < 83.0){
			std::cout << "A" << std::endl;
		}
		else if (a < 43.0&&b < 89.0){
			std::cout << "B" << std::endl;
		}
		else if (a < 50.0&&b < 105.0){
			std::cout << "C" << std::endl;
		}
		else if (a < 55.0&&b < 116.0){
			std::cout << "D" << std::endl;
		}
		else if (a < 70.0&&b < 148.0){
			std::cout << "E" << std::endl;
		}
		else std::cout << "NA" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#define INF 1000000
using namespace std;
int cost[100][100];
int t[100][100];
int d[100];
int m;

void dcost(int s) {
	bool used[100];
	fill(used, used + 100, false);
	fill(d, d + 100, INF);
	d[s] = 0;
	while (1) {
		int v = -1;
		for (int u = 0; u < m; ++u) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;

		for (int u = 0; u < m; ++u) {
			d[u] = d[u] < d[v] + cost[v][u] ? d[u] : d[v] + cost[v][u];
		}
	}
}

void dtime(int s) {
	bool used[100];
	fill(used, used + 100, false);
	fill(d, d + 100, INF);
	d[s] = 0;
	while (1) {
		int v = -1;
		for (int u = 0; u < m; ++u) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;

		for (int u = 0; u < m; ++u) {
			d[u] = d[u] < d[v] + t[v][u] ? d[u] : d[v] + t[v][u];
		}
	}
}

int main() {
	int n, k, a, b, p, q, r;
	
	while (cin >> n >> m, !(n == 0 && m == 0)) {
		fill(cost[0], cost[100], INF);
		fill(t[0], t[100], INF);
		while (n--) {
			cin >> a >> b;
			a--; b--;
			cin >> cost[a][b] >> t[a][b];
			cost[b][a] = cost[a][b];
			t[b][a] = t[a][b];
		}
		cin >> k;
		while (k--) {
			cin >> p >> q >> r;
			p--; q--;
			if (r == 1) dtime(p);
			else dcost(p);
			cout << d[q] << endl;
		}
		
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

const int N=100005,P=1e9+7;
const ll inf=1e18;

int n,ans;
ll A,B,a[N];
int f1[N],s1[N],l1,r1;
int f2[N],s2[N],l2,r2;
inline int chk1(int x){return x>=0?s1[x]:0;}
inline int chk2(int x){return x>=0?s2[x]:0;}

int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	r1=r2=s1[1]=s2[1]=f1[1]=f2[1]=1;
	scanf("%lld",&a[1]);
	for(int i=2;i<=n;i++){
		scanf("%lld",&a[i]);
		while(a[i]-a[r1]>=B)r1++;
		while(a[i]-a[r2]>=A)r2++;
		s1[i]=s1[i-1],s2[i]=s2[i-1];
		if(r2>=l2)f1[i]=(chk2(r2)-chk2(l2-1)+P)%P;
		if(r1>=l1)f2[i]=(chk1(r1)-chk1(l1-1)+P)%P;
		s1[i]=(s1[i]+f1[i])%P;
		s2[i]=(s2[i]+f2[i])%P;
		if(a[i]-a[i-1]<A)l1=i;
		if(a[i]-a[i-1]<B)l2=i;
	}
	ans+=chk1(n)-chk1(l1-1);
	ans+=chk2(n)-chk2(l2-1);
	ans=(ans%P+P)%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int main(){
	int N,A,B;
	cin>>N;
	if(N==1){
		cout<<"Hello World"<<endl;
	}else{
		cin>>A>>B;
		cout<<A+B<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
######################################################
############Created by Devesh Kumar###################
#############devesh1102@gmail.com####################
##########For CodeForces(Devesh1102)#################
#####################2020#############################
######################################################
import sys
input = sys.stdin.readline

# import sys
import heapq 
import copy
import math
import decimal
# import sys.stdout.flush as flush
# from decimal import *
#heapq.heapify(li) 
#
#heapq.heappush(li,4) 
#
#heapq.heappop(li)
#
# &	Bitwise AND Operator	10 & 7 = 2
# |	Bitwise OR Operator	10 | 7 = 15
# ^	Bitwise XOR Operator	10 ^ 7 = 13
 
# <<	Bitwise Left Shift operator	10<<2 = 40
# >>	Bitwise Right Shift Operator
# '''############ ---- Input Functions ---- #######Start#####'''
 

def inp():
	return(int(input()))
def inlt(): 
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(list(s[:len(s) - 1]))
def insr2():
	s = input()
	return((s[:len(s) - 1]))
def invr():
	return(map(int,input().split()))
 ############ ---- Input Functions ---- #######End
 # #####   

def pr_list(a):
	print(*a, sep=" ")
def main():
	# tests =  inp()
	tests = 1
	mod = 998244353
	limit = 10**18
	ans = 0
	for test in range(tests):
		n = inp()
		h = inlt()
		dp = [sys.maxsize for i in range(n+3)]
		dp[0] = 0
		for i in range(0,n):
			if i+1 <n:
				dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1] - h[i]))
			if i+2 <n:
				dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2] - h[i]))
		print(dp[n-1])

if __name__== "__main__":
	main()

Measured memory_bytes: 15816
a,b=map(int,input().split())
st=[2,3,4,5,6,7,8,9,10,11,12,13,1]
a=st.index(a)
b=st.index(b)
if a<b:
    print('Bob')
elif a>b:
    print('Alice')
else:
    print('Draw')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long n;
    long long ans=1;
    long long k;
    
    cin >> n;
    
    for(long long i=1; i<=100000; i++){
        
        if(i*i>n){
            
            break;
            
        }
        
        if(n%i==0){
            
            k = n / i;
            
        }
        
    }
    
    for(int j=1; j<=10; j++){
        
        if(k>=pow(10, j)){
            
            ans = j + 1;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

#define reps(i,j,k) for(int i=(j); i<(k); i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define fr fs
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;

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

int h,w,c;
int inp[9][9], bd[10][9][9];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
void pbd(int n){
		rep(i, h){
			rep(j, w) cout << 1+bd[n][i][j] << " ";
			cout << endl;
		}
		cout << endl;
}
int dfs(int n){
	int d = bd[n+1][0][0];
//	cout << n << endl;
	if(n<0){
	queue<pii> q;
	q.push(pii(0,0));
		// count
//		cout << d << ", " << c << endl;
		if(d != c) return 0;
		int cnt = 0;
		while(!q.empty()){
			pii p = q.front();
			q.pop();
			int x = p.sc, y = p.fs;
			if(bd[n+1][y][x] != d) continue;
			cnt ++;
			bd[n+1][y][x] = -1;
			rep(i,4){
				int cx = x + dx[i], cy = y + dy[i];
				if(cx < 0 || cy < 0 || cx >= w || cy >= h) continue;
				if(bd[n+1][cy][cx] == d) q.push(pii(cy, cx));
			}
		}
//		cout << "cnt : " <<cnt << endl;
		return cnt;
	}
	int ans = 0;
	rep(cur, 6){
		if(d == cur) continue;
	queue<pii> q;
	q.push(pii(0,0));
		memcpy(bd[n], bd[n+1], 9*9*sizeof(int));
//		pbd(n);
		while(!q.empty()){
			pii p = q.front();
			q.pop();
			int x=p.sc, y = p.fs;
			if(bd[n][y][x] != d) continue;
			bd[n][y][x] = cur;
			rep(i,4){
				int cx = x + dx[i], cy = y + dy[i];
				if(cx < 0 || cy < 0 || cx >= w || cy >= h) continue;
				if(bd[n][cy][cx] == d){
					q.push(pii(cy, cx));
				}
			}
		}
//		pbd(n);
		ans = max(ans, dfs(n-1));
	}
	return ans;

}
int main(){
	while(cin >> h >> w >> c, c--){
		rep(i,h)rep(j,w){
			cin >> inp[i][j];
			inp[i][j]--;
		}
		memcpy(bd[5], inp, 9*9*sizeof(int));
//		pbd(5);
		int ans = dfs(4);
		cout << ans <<endl;

	}
	return 0;
}

Measured memory_bytes: 3096
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()

    l = []
    for _ in range(n):
        l.append(input())
    print(len(set(l)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 35600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int A,B;cin >> A >> B;

    if(A<=5)cout << 0<< endl;
    else if(A>=13)cout << B << endl;
    else cout << B/2 << endl;
    return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.length()-1] == b[0] and b[b.length()-1] == c[0]){
		P("YES");
	}else{
		P("NO");
	}
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int a,b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;

  
  return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int n, m;
int a[26];
int d=0;
char c;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>n>>m;
    FOR(i, 1, n) FOR(j, 1, m){
        cin>>c;
        a[c-'a']++;
    }
    FFOR(i, 0, 26) d+=a[i]/4;
    if(d<(m/2)*(n/2)){
        puts("No");
        return 0;
    }
    d=(m/2)*(n/2);
    FFOR(i, 0, 26){
        int x=min(d, a[i]/4);
        d-=x;
        a[i]-=x*4;
    }
    if(m%2) swap(m, n);
    if(n%2){
        if(m%2){
            d=0;
            FFOR(i, 0, 26) d+=a[i]/2;
            if(d<m/2+n/2){
                puts("No");
                return 0;
            }
            puts("Yes");
        }
        else{
            d=0;
            FFOR(i, 0, 26) d+=a[i]/2;
            if(d<m/2){
                puts("No");
                return 0;
            }
            puts("Yes");
        }
    }
    else{
        puts("Yes");
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# GRL_4_B: Path/Cycle - Topological Sort

from collections import namedtuple


DirectedEdge = namedtuple('DirectedEdge', ('src', 'dest'))


def revert(edge):
    return edge._replace(src=edge.dest, dest=edge.src)


class Digraph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, edge):
        self._edges[edge.src].append(edge)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e

    def reversed(self):
        g = self.__class__(self.v)
        for e in self.edges():
            g.add(revert(e))

        return g


def sorted_topological(graph):
    return reverse_post(graph)


def reverse_post(graph):
    def visit(v):
        if not visited[v]:
            visited[v] = True
            return True
        else:
            return False

    def leave(v):
        if not left[v]:
            left[v] = True
            vs.append(v)
        return False

    visited = [False] * graph.v
    left = [False] * graph.v
    vs = []

    for i in range(graph.v):
        if not visited[i]:
            stack = [(i, leave)]
            stack.extend((e.dest, visit) for e in graph.adj(i))
            while stack:
                v, f = stack.pop()
                if f(v):
                    stack.append((v, leave))
                    for e in graph.adj(v):
                        stack.append((e.dest, visit))
    return reversed(vs)


def run():
    v, e = [int(i) for i in input().split()]
    g = Digraph(v)

    for _ in range(e):
        s, t = [int(i) for i in input().split()]
        g.add(DirectedEdge(s, t))

    for v in sorted_topological(g):
        print(v)


if __name__ == '__main__':
    run()



Measured memory_bytes: 13948
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))


for i in range(len(A)):
	A[i] = A[i] % 2

num1 = A.count(1)
num0 = A.count(0)

if P == 0:
	if num1 <= 1:
		print(2 ** (num0))
	else:
		print(2 ** (num0 + num1 - 1))
else:
	if num1 == 0:
		print(0)
	else:
		print(2 ** (num0 + num1 - 1))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d", &a,&b);

	if(a>b){
	printf("a > b\n");
	}else if(a<b){
	printf("a < b\n");
	}else if(a==b){
	printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2048
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10^^9 + 7;

void main() {
    int n;
    scan(n);

    auto s = iota(n + 1).array;
    long ans = 1;

    foreach (p ; 2 .. n + 1) {
        if (s[p] > 1) {
            int cnt = 1;

            for (int q = p; q < n + 1; q += p) {
                while (s[q] % p == 0) {
                    cnt++;
                    s[q] /= p;
                }
            }

            (ans *= cnt) %= mod;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in A:
    res = 0
    for j in range(len(i)):
        res += i[j]*B[j]

    if res + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(ll h)
{
	return h == 1 ? 1 : 1 + 2 * solve(h / 2);
}
int main()
{
	ll h;
	scanf("%lld", &h);
	printf("%lld\n", solve(h));
	return 0;
}

Measured memory_bytes: 384
import sys
from math import ceil
from operator import itemgetter as get

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    n, a, b = rinput()
    print(min(a * n, b))
main() 

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if((a+b)%2==1){
        cout << (a+b+1)/2;
    }else{
        cout << (a+b)/2;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    
    for i in range(h):
        if i==0 or i==(h-1):
            print("#"*w)
        else:
            print("#",end="")
            for j in range(2,w):
                print(".",end="")
            print("#",end="")
            print()
            
    print()


Measured memory_bytes: 7004
import sys
L,R=[int(x) for x in input().strip().split()]

tmp=10**9+1
ans=10**9+1

for i in range(L,R,1):
  for j in range(L+1,R+1,1):
    if i<j:
      ans=min((i*j)%2019,ans)
  
      if ans==0:
        print(0)
        sys.exit()
print(ans)


# 332701087 1753412895

Measured memory_bytes: 3060
s = input()
count = 0
for i in range(3):
    if s[i] == "R":
        count += 1
    elif s[1] == "S":
        count = 0
    if s[1] == "S" and s[2] == "S" and s[0] == "R":
        count = 1
print(count)
    

Measured memory_bytes: 61472
#include <cstdio>
#include <algorithm>
using namespace std;
int n, m, c[1009], s[510009], t[510009], cnt[1027], sum[1027];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort(c, c + n);
		int b = 0;
		for (int i = 0; i <= n; i++) {
			for (int j = i; j <= n && c[i] + c[j] <= m; j++) {
				s[b++] = c[i] + c[j];
			}
		}
		for (int i = 0; i < 30; i += 10) {
			fill(cnt, cnt + 1024, 0); sum[0] = 0;
			for (int j = 0; j < b; j++) cnt[(s[j] >> i) & 1023]++;
			for (int j = 0; j < 1024; j++) sum[j + 1] = sum[j] + cnt[j];
			for (int j = 0; j < b; j++) t[sum[(s[j] >> i) & 1023]++] = s[j];
			for (int j = 0; j < b; j++) s[j] = t[j];
		}
		int r = b - 1, ret = 0;
		for (int i = 0; i < b && i <= r; i++) {
			while (r > 0 && s[i] + s[r] > m) r--;
			ret = max(ret, s[i] + s[r]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 6688
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b,x;
    cin >> a >> b >> x;
    if(x < b){
        cout << x%MOD << endl;
    }else{
        int n = (x-b)/(a-b);
        n %= MOD;
        b %= MOD;
        x %= MOD;
        cout << (x + b*n)%MOD << endl;
    }
}



Measured memory_bytes: 3116
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input!{
        r: i32,
    }
    let ans = 3 * r * r;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =2e5+5;
pair <int,int> p[1005];
ll a[1005],b[1005];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
ll n;
cin>>n;
set <string> s;
string s1;
for(int i=0;i<n;++i){
    cin>>s1;
    s.insert(s1);

}
cout<<s.size();

    return 0;
}

Measured memory_bytes: 19192
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

ans = 0
ai = 0
ci = 0

for b in B:
    while ai < n and A[ai] < b:
        ai += 1
    while ci < n and C[ci] <= b:
        ci += 1
    ans += ai * (n - ci)

print(ans)


Measured memory_bytes: 23328
// D - Friend Suggestions
// UnionFinde version
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (None rank)
	vector<int> parent;//parent number
	public:
	UnionFind(int n){
		parent.resize(n);
		init();
	}
	void init(){//initialize all parent to root
		for(int v=0; v<parent.size(); ++v) parent[v] = v;
	}
	int root(int v){//get root
		if(parent[v]==v) return v;//root
		return parent[v] = root(parent[v]);//path compression
	}
	bool same(int v, int u){//v & u the same set
		return root(v)==root(u);
	}
	void unite(int v, int u){
		v = root(v); u = root(u);
		if(v==u) return;
		parent[v] = u;
	}
	void print(){
		for(auto e:parent){cout<<e<<",";}cout<<"\n";
	}
};

#define MAX 100000+1
int N,M,K;
vvi F(MAX),B(MAX);//friend,block
vi gid(MAX);

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

	UnionFind uni(N+1);

	rp(i,0,M){
		int s,t; cin>>s>>t;
		uni.unite(s,t);
		F[s].push_back(t);
		F[t].push_back(s);
	}

	vi cnt(N+1);rp(i,1,N+1) cnt[uni.root(i)]++;

	rp(i,0,K){
		int s,t; cin>>s>>t;
		if(uni.root(s) != uni.root(t)) continue;
		B[s].push_back(t);
		B[t].push_back(s);
	}

	int self = 1;
	rp(i,1,N+1) cout<< cnt[uni.root(i)]-F[i].size()-B[i].size()-self <<" ";

}

Measured memory_bytes: 13304
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	string s;
	int K;

	cin >> s;
	cin >> K;

	set<string> st;
	st.insert(s.substr(0, 0));
	for (int i = 0; i < s.size(); i++)
	{
		for (int j = 0; j < 15; j++)
		{
			st.insert(s.substr(i, j + 1));
			if (i + j > s.size() - 1)
			{
				break;
			}
		}
	}
	auto itr = st.begin();
	for (int i = 0; i < K; i++)
	{
		itr++;
	}
	cout << *itr << endl;
	return 0;
}

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

int main(){
    int y,m,d;
    while(cin>>y){
        cin>>m>>d;
        if(y>1989||(y==1989&&((m>1)||(d>7)))){
            cout<<"heisei "<<y-1988;
            cout<<" "<<m<<" "<<d<<endl;
        }else if(y>1926||(y==1926&&(m==12&&d>24))){
            cout<<"showa "<<y-1925;
            cout<<" "<<m<<" "<<d<<endl;
        }else if(y>1912||(y==1912&&(m>7||d>29))){
            cout<<"taisho "<<y-1911;
            cout<<" "<<m<<" "<<d<<endl;
        }else if(y>1868||(y==1868&&(m>9||d>7))){
            cout<<"meiji "<<y-1867;
            cout<<" "<<m<<" "<<d<<endl;
        }else{
            cout<<"pre-meiji"<<endl;
        }
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define mod 1000000007

int main()
{


	fast;

	ll  n;
	cin >> n;

	ll a[n], i;
	rep(i, 0, n)
	{
		cin >> a[i];
	}
	ll dp[n];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

int n,k;
int ans;

inline void init()
{
	n=read();k=read();
}

inline void doing()
{
	while(n>=k && (n%k))
	{
		int t=n/k,rest=n%k,num=(rest)/(t+1);
		chkmax(num,1);
		n-=num*(t+1);
		if(n>t*k)n-=t+1;
	}
	if(n>=k && n%k==0)ans^=n/k;
}

int main()
{
	int t=read();
	while(t--)
	{
		init();
		doing();
	}
	if(ans>0)puts("Takahashi");
	else puts("Aoki");
	return 0;
}


Measured memory_bytes: 384