akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n[] = new int[6];
		int n2[] = new int[6];
		int n3[] = new int[6];
		for (int i = 1; i <= 5; i++) {
			n[i] = sc.nextInt();

			if (n[i] % 10 == 0) {
				n2[i] = n[i];
				n3[i] = 10;
			} else {

				n3[i] = n[i] % 10;
				n2[i] = n[i] + (10-n3[i]);
			}
		}
		int min=n3[1]+1;
		int minn=0;
		for (int i = 1; i <= 5; i++) {
			if(min>n3[i]){
				min=n3[i];
			minn=i;
			}
}

int ans=n2[1]+n2[2]+n2[3]+n2[4]+n2[5]-n2[minn]+n[minn];
System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include<stdio.h>

int main(){

int h,w,i,j;

while(1){//?????????????§?

scanf("%d %d",&h,&w);

if(h==0 && w==0)break;

for(i=0;i<h;i++){//i?????????

if((i%2==0)||i==0){
for(j=0;j<w;j++){
if((j%2==0)||j==0){
printf("#");
}else{
printf(".");
}
}

}else{
for(j=0;j<w;j++){
if((j%2==0)||j==0){
printf(".");
}else{
printf("#");
}

}
}
printf("\n");
}//i?????????
printf("\n");
}//???????????????
return 0;
}

Measured memory_bytes: 572
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

f = [[False]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      f[i][j] = True
      
if f[0][0] and f[0][1] and f[0][2]:
  print("Yes")
elif f[1][0] and f[1][1] and f[1][2]:
  print("Yes")
elif f[2][0] and f[2][1] and f[2][2]:
  print("Yes")
elif f[0][0] and f[1][0] and f[2][0]:
  print("Yes")
elif f[0][1] and f[1][1] and f[2][1]:
  print("Yes")
elif f[0][2] and f[1][2] and f[2][2]:
  print("Yes")
elif f[0][0] and f[1][1] and f[2][2]:
  print("Yes")
elif f[0][2] and f[1][1] and f[2][0]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3192
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}
 
t = Array.new(n+1){ 0 } 
used = Array.new(n+1){ false }
 
s = 1
t[1] = 1
i = 1
used[1] = true
loop do
  
  s = a[s]
  
  if i == k
    puts s
    exit
  end
  
  used[s] ? break : used[s] = true
  
  i +=1
  t[s] = i
end

dist = (t[s] - 1)
cycle = i - dist
 
if dist >= k
  puts s
else
  idx = (k - dist) % cycle + dist + 1
  puts t.index(idx)
end

Measured memory_bytes: 32068
/*                  ___
               :                
               ;                
              :                 
              ;                 
             /                  
           o/                   
         ._/\___,                
             \                  
             /                   
             `      
	bug
*/
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

string str;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> str;
	int A=0,C=0,n=str.length();
	bool flag=true;

	for(char c: str){
		if(c=='A')
			A++;
		else if(c=='C')
			C++;
		if(isupper(c) && c!='A' && c!='C'){
			flag=false;
			break;
		}
	}

	if(!flag){
		cout << "WA\n";
		return 0;
	}

	if(A==1 && C==1){
		if(str[0]=='A' && str[n-1]!='C' && str[1]!='C'){
			cout << "AC\n";
		}else{
			cout << "WA\n";
		}
	}else{
		cout << "WA\n";
	}

    //cerr << tick();

	return 0;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;
// void mergeSort(vector<int> &a,int l,int r,LL &re){
//     if(l>r) return;
//     int m = (r+l)/2;
//     mergeSort(a,l,m,re);
//     mergeSort(a,m+1,r,re);

// }

void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> table(n,0);
    for(int i=0;i<n;i++) cin>>table[i];
    sort(table.begin(),table.end());
    LL ans = 0;
    for(int i=0;i<(n-k);i++){
        ans+=table[i];
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF)
    {
    y=(c*d-a*f)/(b*d-a*e);
    x=(c*e-b*f)/(a*e-b*d);
        if(x==0)
            x=0.0;
        if(y==0)
            y=0.0;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
long long n, m, i, j, k, t,x ,y;
int main(){
	cin>>x>>y;
	if(x%y==0){
		cout<<-1;
		return 0;
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    double a,b,x;
    double PI = 3.14159265;
    cin >> a>>b>>x;
    double c=0;
    if(x<=a*a*b/2){
        c = atan(a*b*b/(2*x));
    }else{
        c = atan((2*a*a*b-2*x)/(a*a*a));
    }
    
    cout << setprecision(10)<<c*180.0/PI<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
	int a,b,x;
	std::cin >> x >> a >> b;
	if (b - a <= 0) {
		std::cout << "delicious" << '\n';
	}
	else if (b - a <= x) {
		std::cout << "safe" << '\n';
	}
	else {
		std::cout << "dangerous" << '\n';
	}
	return 0;
}


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

int main(){
    int d,g;
    cin >> d >> g;
    vi p(d),c(d);
    rep(i,d) cin >> p[i] >> c[i];
    int ans=1e4;
    for(int i=0;i<(1<<d);i++){
        int now=0;
        int mondai=0;
        for(int j=0;j<d;j++){
            if((i>>j)%2 and 1){
                now+=p[j]*100*(j+1)+c[j];
                mondai+=p[j];
            }
        }
        if(now>=g){
            ans=min(mondai,ans);
            continue;
        }
        for(int j=d-1;j>=0;j--){
            if((i>>j)%2==0){
                for(int k=0;k<p[j];k++){
                    now+=100*(j+1);
                    mondai++;
                    if(now>=g){
                        ans=min(mondai,ans);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int count(vector<int> v){
    int n = v.size();
    vector<int> x(n);
    REP(i,n){x[i]=i+1;}
    int itr = 0;
    do{
        if(x==v)break;
        itr++;
    }while(next_permutation(x.begin(),x.end()));
    
    return itr;
}

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    REP(i,n){cin>>p[i];}
    REP(i,n){cin>>q[i];}
    cout << abs(count(p)-count(q)) << endl;
    return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


int N;


signed main(){
    cin >> N;

    cout << N*(N-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

const int MAX = 5000;

// s[i]のk文字後にs[j]が重なっても良いか
bool check[3][3][MAX];

bool compare(char u, char v){
    if(u == '?') return true;
    if(v == '?') return true;
    if(u == v) return true;
    else return false;
}

int main(){
    vector<string> s(3);
    rep(i,3) cin >> s[i];

    rep(i,3)rep(j,3)rep(k,MAX) check[i][j][k] = true;

    rep(i,3)rep(j,3){
        rep(k,s[i].size()){
            for(int l = k; l < s[i].size(); l++){
                int m = l - k;
                if(m >= s[j].size()) break;
                if(!compare(s[i][l], s[j][m])){
                    check[i][j][k] = false;
                    break;
                }
            }
        }
    }

    // rep(k,5){
    //     cout << check[0][1][k] << " ";
    // }
    // cout << endl;

    int ans = 10000;
    vector<int> p = {0,1,2};
    do {
        rep(x,2005)rep(y,2005){
            if(!check[p[0]][p[1]][x]) continue;
            if(!check[p[1]][p[2]][y]) continue;
            if(!check[p[0]][p[2]][x+y]) continue;
            
            int val = s[p[0]].size();
            chmax(val, s[p[1]].size() + x);
            chmax(val, s[p[2]].size() + x + y);
            chmin(ans, val);
        }
    } while (next_permutation(p.begin(), p.end()));

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println(x < 1200 ? "ABC" : "ARC");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;
    cin>>n;
    int aho[n+1];
    for(int i = 0;i<n;i++){
      int a; cin >>a;
      aho[a] = i+1;
    }
    for(int i = 1;i<=n;i++)cout<<aho[i]<<" ";
    return 0;
}

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

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

using namespace std;

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

int main() {
  int a, b, t;
  cin >> a >> b >> t;

  int result = 0;
  int tmp = a;
  while (tmp <= t + 0.5) {
    tmp += a;
    result += b;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let a: Vec<usize> = {
        let mut v: Vec<usize> = Vec::new();
        for _ in 0..n {
            let v_i = {
                let mut s = String::new();
                std::io::stdin().read_line(&mut s).unwrap();
                let s = s.trim_right().to_owned();
                s.parse().unwrap()
            };
            v.push(v_i)
        }
        v
    };

    if a[0] != 0 {
        println!("{}", -1);
        return;
    }

    let mut ans = 0;
    ans += a[n - 1];
    for i in (0..(n - 1)).rev() {
        if a[i] + 1 < a[i + 1] {
            println!("{}", -1);
            return;
        } else if a[i] + 1 == a[i + 1] {
        } else {
            ans += a[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define For(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

int main() {
    ll N,K;
    cin >> N >> K;
    N%=K;
    ll ans;
    if(N==0) ans=0;
    ll m=N-K;
    absll(m);
    if(m<=N) ans=m;
    else ans=N;
    cout << ans << endl;
}

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

using namespace std;

#define Nil -1

struct Node {
  int parent;
  int left_child;
  int right_sibling;
};

int main() {
  int N;  // number of nodes
  cin >> N;

  Node nodes[N];

  for (int i = 0; i < N; i++) {
    nodes[i].parent = Nil;
    nodes[i].left_child = Nil;
    nodes[i].right_sibling = Nil;
  }

  for (int i = 0; i < N; i++) {
    int parent, degree;
    cin >> parent >> degree;
    int prev_child;
    for (int d = 0; d < degree; d++) {
      int child;
      cin >> child;
      nodes[child].parent = parent;
      if (d == 0) {
        nodes[parent].left_child = child;
      } else {
        nodes[prev_child].right_sibling = child;
      }
      prev_child = child;
    }
  }

  int depths[N];
  for (int i = 0; i < N; i++) {
    int depth = 0;
    int id = i;
    while (nodes[id].parent != Nil) {
      depth++;
      id = nodes[id].parent;
    }
    depths[i] = depth;
  }

  for (int i = 0; i < N; i++) {
    cout << "node " << i << ": parent = " << nodes[i].parent << ", depth = " << depths[i] << ", ";
    if (nodes[i].parent == Nil) {
      cout << "root";
    } else if (nodes[i].left_child == Nil) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << ", [";
    int child = nodes[i].left_child;
    bool first = true;
    while (child != Nil) {
      if (!first) {
        cout << ", ";
      }
      first = false;
      cout << child;
      child = nodes[child].right_sibling;
    }
    cout << "]" << endl;
  }
}


Measured memory_bytes: 4668
n,k = map(int, input().split())

lrs = []
for _ in range(k):
    l,r = map(int, input().split())
    lrs.append((l,r))

dp = [0]*(n+1)
sdp = [0]*(n+1)
dp[1] = 1
sdp[1] = 1

MOD = 998244353
for i in range(2,n+1):
    # print('------',i)
    for l,r in lrs:
        dr = sdp[i-l] if i-l >= 0 else 0
        dl = sdp[i-r-1] if i-r-1 >= 0 else 0
        # print(dl,dr,'--')
        dp[i] += (dr-dl)
        dp[i] %= MOD        
    sdp[i] = sdp[i-1] + dp[i]
    sdp[i]%=MOD

# print(dp)
print(dp[n])

Measured memory_bytes: 71648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    ll x,k,d;
   cin>>x>>k>>d;
   x = abs(x);
   if(x<d){
       if(k%2==0){
           cout<<x<<endl;
       }else{
           cout<<abs(x-d)<<endl;
       }
   }else if(x==d){
       if(k%2==0){
           cout<<x<<endl;
       }else{
           cout<<0<<endl;
       }
   }else{
       ll rem = min(k,x/d);
       k-=rem;
       x-=d*rem;
       if(k){
            if(k%2==0){
                cout<<x<<endl;
            }else{
                cout<<abs(x-d)<<endl;
            }
       }else{
           cout<<x<<endl;
       }
   }
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		int num = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= 3) {
				if (i == 2 || i == 3) num++;
				continue;
			}
			else {
				if (i % 2 == 0 || i % 3 == 0) continue;
				if (i % 6 != 1 && i % 6 != 5) continue;
				bool check = true;
				for (int j = 5; j * j <= i; j += 6) {
					if (i % j == 0) check = false;
					if (i % (j + 2) == 0) check = false;
					if (check == false) break;
				}
				if (check == true) num++;
			}
		}
		cout << num << endl;
	}
	return 0;
}


Measured memory_bytes: 3016
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

string itos(int a){
  string s;
  int k = 1000;
  for(int i=0;i<4;i++){
    s.push_back(a/k+'0');
    a -= (a/k)*k;
    k/=10;
  }
  return s;
}

pair<int,int> hitblow(string a,string b){
  pair<int,int> res;
  res.first = 0;
  res.second = 0;
  bool ca[10],cb[10];
  for(int i=0;i<10;i++){
    ca[i] = false;
    cb[i] = false;
  }
  for(int i=0;i<(int)a.size();i++){
    if(a[i] == b[i])res.first++;
    else{
      ca[a[i]-'0'] = true;
      cb[b[i]-'0'] = true;
      if(cb[a[i]-'0'])res.second++;
      if(ca[b[i]-'0'])res.second++;
    }
  }
  return res;
}

int main(){
  bool check[10000],hoge[10000];
  string str;
  int h,b,n;

  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
	for(int l=0;l<10;l++){
	  if(i==j || i== k|| i==l || j==k || j==l || k==l){
	    hoge[i*1000+j*100+k*10+l] = false;
	  }else{
	    hoge[i*1000+j*100+k*10+l] = true;
	  }
	}
      }
    }
  }

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<10000;i++)check[i] = hoge[i];

    for(int i=0;i<n;i++){
      cin >> str >> h >> b;
      for(int i=0;i<10000;i++){
	if(check[i]){
	  pair<int,int> tmp;
	  tmp = hitblow(itos(i),str);
	  check[i] = (tmp.first == h) && (tmp.second == b);
	}
      }
    }
 
    int c = 0;
    for(int i=0;i<10000;i++){
      if(check[i])c++;
    }
    if(c==1){
      for(int i=0;i<10000;i++){
	if(check[i])cout << itos(i) << endl;
      }
    }else{
      vector<int> can;
      for(int i=0;i<10000;i++){
	if(check[i])can.push_back(i);
      }
      int i;
      for(i=0;i<10000;i++){
	if(hoge[i]){
	  int hb[5][5];
	  for(int j=0;j<5;j++){
	    for(int k=0;k<5;k++)hb[j][k] = 0;
	  }
	  bool f = true;
	  for(int j=0;j<(int)can.size();j++){
	    pair<int,int> tmp;
	    tmp = hitblow(itos(i),itos(can[j]));
	    hb[tmp.first][tmp.second]++;
	    if(hb[tmp.first][tmp.second]>=2){
	      f = false;
	      break;
	    }
	  }

	  if(f){
	    cout << itos(i) << endl;
	    break;
	  }
	}
      }
      if(i==10000)cout << "????" << endl;
    }
  }
}

Measured memory_bytes: 948
package main

import "fmt"

func main() {
    var N, M, flipped int
    fmt.Scan(&N, &M)
    if N == 1 {
        N += 2
    }
    if M == 1 {
        M += 2
    }
    flipped = (N-2)*(M-2)
    
    fmt.Println(flipped)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c[10]; cin >> c;

    if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
n = int(input())
for i in range(n):
    k = int(input())
    for j in range(3):
        if k == a[j]:
            a[j] = 0
        if k == b[j]:
            b[j] = 0
        if k == c[j]:
            c[j] = 0

if (sum(a) == 0) or (sum(b) == 0) or (sum(c) == 0):
    print("Yes")
    exit(0)

for h in range(3):
    if a[h]+b[h]+c[h] == 0:
        print("Yes")
        exit(0)

hh = a[0]+b[1]+c[2]
ee = a[2]+b[1]+c[0]
if (hh == 0) or (ee == 0):
    print("Yes")
    exit(0)

print("No")

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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if(n%10 == 7 || (n/10)%10 == 7 || (n/100) == 7) cout << "Yes";
	else cout<<"No";
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(3*N);
  for(int i = 0; i < 3*N; ++i) cin >> A[i];
  priority_queue<int> pque, pque2;
  long long int s = 0, t = 0;
  for(int i = 0; i < N; ++i){
    pque.push(-A[i]);
    s += A[i];
    pque2.push(A[3*N-1-i]);
    t += A[3*N-1-i];
  }
  vector<long long int> S(N+1,0);
  S[0] = s;
  //cout << s << endl;
  long long int ans = s - t;
  for(int i = N; i < 2*N; ++i){
    int a = -pque.top();
    if(a < A[i]){
      s += A[i] - a;
      pque.pop();
      pque.push(-A[i]);
    }
    //cout << i - N + 1 << " : s = " << s << endl;
    S[i-N+1] = s;
  }
  //cout << t << endl;
  S[N] -= t;
  for(int i = 2*N - 1; i >= N; --i){
    int a = pque2.top();
    if(a > A[i]){
      t += A[i] - a;
      pque2.pop();
      pque2.push(A[i]);
    }
    //cout << i - N << " : t = " << t << endl;
    S[i-N] -= t;
  }
  for(int i = 0; i < N+1; ++i){
    ans = max(ans, S[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ii d[MAXn];
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    REP (i,n) cin >> d[i].X >> d[i].Y;
    sort(d,d+n);
    ll ans = 0;
    REP (i,n) {
        if (!m) break;
        if (m-d[i].Y >= 0) {
            ans += d[i].X * d[i].Y;
            m -= d[i].Y;
        }
        else {
            ans += d[i].X * m;
            m = 0;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

void solve() {
  string s;
  int a = 0, b = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A')
      a++;
    else
      b++;
  }
  if (a > 0 && b > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())

V = 0
for i in range(N):
    V += (N - i) * (i + 1)

E = 0
for _ in range(N - 1):
    u, v = map(int, sys.stdin.readline().rstrip().split())
    if u > v:
        u, v = v, u
    E += u * (N - v + 1)

# print(V,E)
print(V - E)


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

int n, s, ans;
ll a[3030], dp[3030][3030];
const ll MOD = 998244353;


int main(){
    cin >> n >> s;
    rep(i,n) cin >> a[i];

    rep(i,n) {
        rep(j,s+1) {
            dp[i+1][j] += dp[i][j];
            int prev = j - a[i];
            if (prev > 0) dp[i+1][j] += dp[i][prev];
            else if (prev == 0) dp[i+1][j] += i+1;
            dp[i+1][j] %= MOD;
        }
        ans = (ans + dp[i+1][s] * (n - i) % MOD) % MOD;
        dp[i+1][s] = 0;
    }

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

Measured memory_bytes: 74680
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 29, 2020 6:00 PM
 *    Problem Name  : C - Sum of product of pairs
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc177/tasks/abc177_c
 *    @genarated by : ai-virtual-assistant
 **/

#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll arr[n+1],sum=0,total=0;

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

    for(ll i=0; i<n; i++){
        sum = sum  - arr[i];
        total = ((total%mod) + ((sum % mod) * arr[i])%mod)%mod;
    }
    cout << total % mod << endl;
   
    return 0 ;
}


Measured memory_bytes: 5208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  long long int n=0;
  cin >> n;
  long long int ans=0;
  int i=0;
  int amari=0;
  vector<int>dog;
  while(n>0){
    if(n%26 == 0){
      amari=n%26;
      dog.push_back(amari);
      n/=26;
      n--;
      continue;
    }
    amari=n%26;
    dog.push_back(amari);
    n/=26;
  }
  reverse(begin(dog),end(dog));
  for(int i=0;i<(dog.size());i++){
    char c;
    if(dog.at(i) == 0){
      cout << "z";
      continue;
    }
    c = dog.at(i)+96;
    cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int,int>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb(x) pupsh_back(x)
int32_t main() {
    int t=1;
   
    while(t--)
    {
        int A,B,C;
        cin>>A>>B>>C;
        cout<<C<<" "<<A<<" "<<B;
        cout<<endl;     
    }
    
//    cout<<"Sum of x+y = " << z;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,X,Y;
    cin>>n>>X>>Y;
    vi ans(n,0);
    ll si=Y-X+1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {
            ll d;
            if(i<X )
            {
                if(j<X)
                {
                    d=j-i;
                }
                else if(j>Y)
                {
                    // dist(x,y)=1;
                    d=j-Y+1;
                    d+=X-i;
                }
                else//in the cycle
                {
                    ll d1=j-i;
                    ll d2=Y-j+1+X-i;
                    d=min(d1,d2);
                }
            }
            else if(i>Y)
            {
                //j>Y
                d=j-i;
            }
            else//i is in the cycle 
            {
                if(j>Y)
                {
                    ll d1=j-i;
                    ll d2=i-X+1+j-Y;
                    d=min(d1,d2);
                }
                else//j also in the cycle
                {
                    ll d1=j-i;
                    ll d2=si-d1;
                    d=min(d1,d2);
                }
            }
            ans[d]++;
        }
    }
    for(ll k=1;k<n;k++)
        cout<<ans[k]<<"\n";
}


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

void frog(vector<int> h, int N){
    vector<int> ans(N);
    for (int i = 0; i < N - 1; i++) {
        if (i == 0) {
            ans.at(i + 1) = abs(h.at(i + 1) - h.at(i));
        }
        else {
            ans.at(i + 1) = min(ans.at(i) + abs(h.at(i + 1) - h.at(i)), 
            ans.at(i - 1) + abs(h.at(i + 1) - h.at(i - 1)));
        }
    }
    cout << ans.at(N - 1) << endl;
    return;
}

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    frog(h, N);
}


Measured memory_bytes: 1408
while True:
    try:
        n = int(raw_input())
        count = 0
        for i in range(10):
           for j in range(10):
                for k in range(10):
                    for l in range(10):
                         if i+j+k+l == n:
                             count += 1
        print count
    except:
        break

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

int main(){
 char c;

cin >> c;

if(c == 'a' || c == 'i' || c == 'u' || c== 'e' || c== 'o' )
cout <<"vowel"<<endl;

else
cout << "consonant" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1ll<<60
using namespace std;
int gcd(int a,int b){
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int N;
  cin>>N;
  vector<int>vet(N);
  for(int i=0;i<N;i++)
  	cin>>vet[i];
  sort(vet.begin(),vet.end());
  double soma=vet[0]+vet[1];
  soma/=2.0;
  for(int i=2;i<N;i++){
  	soma+=vet[i];
  	soma/=2.0;
  }
  cout<<soma<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long lint;

using namespace std;
int ans = 99999999;

int N, A, B, C;
vector<int> bamboo(8, 0); // 初期値は0

// cost
// +1 or -1 : 1MP
// x + y : 10MP

// A,B,Cの長さを作る
// 状態数4**Nの木を深さ優先探索
/*
	// 
	択：
		A. 長さAのもと (0)
		B. 長さBのもと (1)
		C. 長さCのもと (2)
		X. 使われない (3)
	
	init
	(*) -> A[1] // 0
			-> B[1] // 1
			-> C[1] // 2
			-> X[1] // 3
		
			ex.
			A[1] -> A[2]
					 -> B[2]
					 -> C[2]
					 -> X[2]
			
			costを格納
	*/

int r0, r1, r2, r3;
vector<int> v(8);

int calc(vector<int> v, vector<int> bamboo, int n)
{
	int tmp = 0;
	int merged[4] = {};
	int used[4] = {};

	for (int i = 0; i < n; i++)
	{
		merged[v[i]] += bamboo[i];
		if (v[i] < 3)
		{
			if (used[v[i]])
			{
				tmp += 10; // merge: 10MP
			}
			used[v[i]] = 1;
		}
	}

	/*
	for (auto vv: v) {
		cout << vv ;
	}
	cout << endl;

*/
	tmp += abs(A - merged[0]);
	tmp += abs(B - merged[1]);
	tmp += abs(C - merged[2]);

	if (used[0] && used[1] && used[2])
	{
		/*
		for (auto vv: v) {
			cout << vv ;
		}
		*/
		//		cout << endl;
		//		cout << tmp << endl;;
		return tmp;
	}
	else
		return -1;
}
void dfs(int depth, vector<int> v, vector<int> bamboo, int n)
{ // depth: 深さ, v[0-2]: 竹の長さ．A,B,Cが作れたか？
	if (depth == n)
	{
		// 一番下まで来た
		// コストを計算する

		//d.b.

		int tmp = calc(v, bamboo, n);

		//cout << tmp << endl;
		if (tmp != -1)
		{
			ans = min(ans, tmp);
		}
		return;
	}

	// Aに使われるときの処理
	// Bに使われるときの処理
	// Cに使われるときの処理
	// 使われないときの処理

	for (int i = 0; i < 4; i++)
	{
		v[depth] = i;
		dfs(depth + 1, v, bamboo, n);
	}
}

int main()
{
	cin >> N >> A >> B >> C;
	rep(i, N) cin >> bamboo[i];

	dfs(0, v, bamboo, N);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k=0;
	cin>>n;
	char s[n];
	int b[n];
	b[0]=0;
	for(int i=0;i<n;i++)
	cin>>s[i];
	int c=1;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		k++;
		else if(s[i]=='D')
		k--;
		b[c++]=k;
		
	}
	sort(b,b+c,greater<int>());
	cout<<b[0];
	
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;


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

    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP (i, N) cin >> V[i];

    // 選ぶ個数と捨てる個数を設定する
    int ans = 0;
    REP (i, min(N, K) + 1) {
        int choose = i;
        REP (j, N + 1) {
            vector<int> get;
            REP (k, choose) {
                if (k < j) get.push_back(V[k]);
                else get.push_back(V[N-choose+k]);
            }
            sort(get.begin(), get.end(), greater<int>());
            int ignore = min(choose, K - choose);
            // cout << "i:" << i << " ignore:" << ignore << "\n";
            // cout << "get: ";
            // for (auto e : get) cout << e << " ";
            // cout << "\n";
            REP (l, ignore) {
                if (get[get.size()-1] < 0) get.pop_back();
            }
            int check = 0;
            for (auto e : get) {
                check += e;
            }
            // cout << "check:" << check << "\n";
            ans = max(ans, check);
        }
    }

    cout <<ans << "\n";
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
using namespace std;
map<int , int >mp;
void findfactors(int x)
{
	vi g;
	for(int i=1;i<=sqrt(x);i++)
	{
		if(x%i==0)
		{
			if(x/i==i)
				g.pb(i);
			else
				g.pb(i), g.pb(x/i);
		}
	}
	sort(g.begin(),g.end());
//	for(int i=0;i<g.size();i++)	cout<<g[i]<<" ";
//	cout<<endl;
	int num=x;
	for(int i=0;i<g.size();i++)
	{
		int temp=g[i];
		if(prime[temp])
		{
			int cnt=0;
			while(num%temp==0 && num>0)
			{
				num/=temp;
				cnt++;
			}
			mp[temp]=max(mp[temp],cnt);
		}
	}
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
int solve()
{
	sieve();
	int n;
	cin>>n;
	int a[n], l=1;
	for(int i=0;i<n;i++)						cin>>a[i];
	for(int i=0;i<n;i++)						findfactors(a[i]);
	for(auto it=mp.begin();it!=mp.end();it++)	l=(power(it->first,it->second)*l)%mod;
	findinverse();
	int sum=0;
	for(int i=0;i<n;i++)
	{
		sum=(sum+(l*inv[a[i]])%mod)%mod;
	}
	cout<<sum<<endl;
}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s, t;
	int con = 0;
	
	cin>>s>>t;
	
	if(s[0] == t[0]) con++;
	if(s[1] == t[1]) con++;
	if(s[2] == t[2]) con++;
	
	cout<<con<<endl;
	
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  div_t d; d.quot = N; d.rem = 0;
  int fx = 0;
  while (d.quot) {
    d = div(d.quot, 10);
    fx += d.rem;
  }
  const char* result = "No";
  if (N % fx == 0) result = "Yes";
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    e = int(input())
    if e == 0:
        break
    mz = int( e **(1/3))+1
    L = []
    for k in range(mz+1):
        ek = e-k**3
        if ek < 0:
            break
        j = int(ek**0.5)
        i = ek - j**2
        if i >= 0 and j >= 0 and k >=0:
            L.append((i+j+k))
    print(min(L))




Measured memory_bytes: 5716
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	int sum_value = 0;

	vector<int> V(N);
	vector<int> C(N);

	REP(i, N) {
		cin >> V[i];
	}
	REP(i, N) {
		cin >> C[i];
	}

	REP(i, N) {
		sum_value += max(V[i] - C[i], 0);
	}

	cout << sum_value << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
# now_t, now_x, now_y
nt, nx, ny = 0, 0, 0
l = [list(map(int, input().split())) for _ in range(n)]
for t, x, y in l:
    dist =  abs(nx - x) + abs(ny - y)
    if dist > t - nt:
        print("No")
        exit()
    elif (dist - (t-nt)) % 2 != 0:
        print("No")
        exit()
    nt, nx, ny = t, x, y
print("Yes")

Measured memory_bytes: 27380
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string t; cin >> t;
    int si = SIZE(t);
    rep(i,si){
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m,l;
  cin>>n>>m>>l;
  vector< vector<Int> > G(n,vector<Int>(n,l+1));
  for(Int i=0;i<n;i++) G[i][i]=0;
  for(Int i=0;i<m;i++){
    Int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    chmin(G[a][b],c);
    chmin(G[b][a],c);
  }

  for(Int k=0;k<n;k++)
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
        chmin(G[i][j],G[i][k]+G[k][j]);

  const Int INF = 1e9;
  vector< vector<Int> > H(n,vector<Int>(n,INF));
  for(Int i=0;i<n;i++) H[i][i]=0;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      if(G[i][j]<=l) chmin(H[i][j],1);

  for(Int k=0;k<n;k++)
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
        chmin(H[i][j],H[i][k]+H[k][j]);

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int s,t;
    cin>>s>>t;
    s--;t--;
    if(H[s][t]==INF) cout<<-1<<"\n";
    else cout<<H[s][t]-1<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	
	string a, b;
	cin >> a >> b;
	
	cout << b<<a<< endl;
}

Measured memory_bytes: 256