akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var _C = cin.ReadStrArray(2);
            var C = new char[2, 3];
            for(int i = 0; i < 2; i++)
            {
                var s = _C[i].ToCharArray();
                for(int j = 0; j < 3; j++)
                {
                    C[i, j] = s[j];
                }
            }
            if (C[0, 1] == C[1, 1] && C[0, 0] == C[1, 2] && C[0, 2] == C[1, 0])
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
h, w = list(map(int, input().split()))

wordlist = []

for i in range(h):
  wordlist.append(list(input().split()))


output_string = []
for i in range(h):
  for j in range(2):
    output_string.append(wordlist[i])


for i in range(h * 2):
  print("".join(output_string[i]))


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

#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)

using namespace std;

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

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 素因数を列挙
vector<pair<ll, ll>> enumeratePrimeFactors(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) {
      continue;
    }
    ll ex = 0; // 指数
    // 割れるだけ割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.emplace_back(a, ex);
  }
  // nが一度も割られなかった場合
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  bool pairwiseCoprime = true;
  vector<vector<pair<ll, ll>>> d(n);
  rep(i, n) {
    d.at(i) = enumeratePrimeFactors(a.at(i));
  }
  set<ll> s;
  rep(i, n) {
    rep(j, d.at(i).size()) {
      ll dd = d.at(i).at(j).first;
      if (s.count(dd)) {
        pairwiseCoprime = false;
        break;
      } else {
        s.insert(dd);
      }
    }
    if (!pairwiseCoprime) {
      break;
    }
  }
  ll gcdSum = 0;
  rep(i, n) {
    gcdSum = gcd(gcdSum, a.at(i));
  }
  bool setwiseCoprime = gcdSum == 1;
  if (pairwiseCoprime) {
    cout << "pairwise coprime" << endl;
  } else if (setwiseCoprime) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 168352
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main () {
    int n ;
    cin >> n ;
    vector<int> b (n - 1) ;
    rep(i, n - 1){
        cin >> b[i] ;
    }
    int ans = 0 ;
    int t = 100005;
    rep(i , n - 1){
        ans += min(t, b[i]) ;
        t = b[i] ;
    }
    ans += b[n - 2] ;
    cout << ans << endl ;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void insertionSort(vl &a,ll n){
    rep(i,n){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    fore(i,1,n-1){
        ll v=a[i];
        ll j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        rep(i,n){
            if(i>0)cout<<" ";
            cout<<a[i];
        }
        cout<<endl;
    }
}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    insertionSort(a,n);
}

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



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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
		}
		int[] r = new int[n+10];
		Arrays.fill(r, 0);
		for (int i = 0; i < m; i++) {
			r[a[i]]++;
			r[b[i]]++;
		}
		for (int i = 1; i <= n; i++) {			
			System.out.println(r[i]);
		}
	}
}


Measured memory_bytes: 21332
#include<stdio.h>
int main()
{
  int i;
  double sum;
  int N;
  scanf("%d",&N);
  double x[N];
  char u[N][4];
  
  for(i=0; i<N; i++){
  	scanf("%lf",&x[i]);
  	scanf("%s",u[i]);
    if(u[i][0]=='J'){
      sum+=x[i];}
    else if(u[i][0]=='B'){
      sum+=x[i]*380000;}
  }
  
  printf("%f",sum);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
void sway(int& x,int& y)
{


    if(x>y)
        printf("%d %d\n",y,x);
    else
        printf("%d %d\n",x,y);


}
int main()
{
   int a,b;
   while(true)
   {
      scanf("%d%d",&a,&b);
      if(a==0&&b==0)
        break;
    sway(a,b);
   }


}



Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(2e5)+5;


int ar[ms];


int main()
{
    idfc;

    int k,t;
    cin>>k>>t;

    int i;

    for(i=1;i<=t;i++)cin>>ar[i];
    int pr=-1;
    int j;
    int a=0;
    int c;int p;
    for(i=1;i<=k;i++)
    {
        if(i&1)
        {
            c=0; p=0;
            for(j=1;j<=t;j++)
            {
                if(j==pr)continue;
                if(ar[j])
                {
                    if(ar[j]>p)
                    {
                        c=j;
                        p=ar[j];
                    }
                }
            }
            if(c){ar[c]--;pr=c;}
            else {a++;ar[pr]--;}
        }
        else{
            c=0;
            p=INT_MAX;
            for(j=1;j<=t;j++)
            {
                if(j==pr)continue;
                if(ar[j])
                {
                    if(p>ar[j])
                    {
                        p=ar[j];
                        c=j;
                    }
                }
            }
            if(c)
            {
                ar[c]--;
                pr=c;
            }
            else{
                ar[pr]--;
                a++;
            }
        }
    }

    cout<<a;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  int min = pow(10,9);
  int H,num;
  
  for (int i= 0; i < N; i++){
    cin >> H;
    if(min > abs(A*1000 - (T*1000 - 6 * H)) ){
      min = abs(A*1000 - (T*1000 - 6 * H));
      num = i + 1;
    }
  }
  cout << num <<  endl;
}

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

int main(){
 	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	string s="";
	for(int i = 0; i<tx-sx;i++)
		s+="R";
	for(int i = 0; i<ty-sy;i++)
		s+="U";//t
	for(int i = 0; i<tx-sx;i++)
		s+="L";
	for(int i = 0; i<=ty-sy;i++)
		s+="D";//s -1
	for(int i = 0; i<=tx-sx;i++)
		s+="R";
	for(int i = 0; i<=ty-sy;i++)
		s+="U";
	s+="LU";
	for(int i = 0; i<=tx-sx;i++)
		s+="L";
	for(int i = 0; i<=ty-sy;i++)
		s+="D";
	s+="R";
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin >> n;
  
  P ab[n];
  rep(i,n) cin >> ab[i].second >> ab[i].first;
  
  sort(ab,ab+n);
  
  int time = 0;
  bool ok = true;
  rep(i,n){
    time += ab[i].second;
    if(time > ab[i].first) ok = false;
  }
  
  cout << ( ok ? "Yes" : "No" ) << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;



int main(){
    while(true){
        int w,d;cin>>w>>d;
        if(!w)break;
        map<int,int> m;
        int ans=0;
        rep(i,w){
            int a;cin>>a;
            m[a]++;
            ans+=a;
        }
        rep(i,d){
            int a;cin>>a;
            m[a]--;
        }
        for(auto it=m.begin();it!=m.end();++it){
            if(it->second<0)ans-=(it->first)*(it->second);
        }
        cout<<ans<<endl;
    }
}




Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        for (int i = 0; i < 120; i++) {
            for (int j = -120; j < 120; j++) {
                if (Math.pow(i, 5) - Math.pow(j, 5) == x){
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 38712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		
		out.println((a+b)*h/2);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

map<string,int> mp;

int main(){
    int n;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    int max=-1;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(itr->second>=max)max=itr->second;
    }
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(max==itr->second)cout<<itr->first<<endl;
    }

    return 0;
}

Measured memory_bytes: 25216
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] list = new int[N];
        for (int i = 0 ; i < N ; i++) {
        	list[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        int max = 0;
        int count = 0 ;
        for (int i = 0; i< N-1; i++) {
        	if (list[i] >= list[i+1]) {
        		count++;
        	}
        	else {count = 0;
        		}
        	
      		if (max < count) {
    			max = count;
      		}

        }
        System.out.println(max);



    }
}


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

int main() {
int N;
cin>>N;
int X = 114514;
for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
        if(j*i==N){
            X = 1;
        }
        }
    }
if (X==1){
    cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;

double standardDeviation(int num)
{
	int i, *data = new int[num];
	double median, total = 0;

	for (i = 0; i < num; i++)
	{
		cin >> data[i];
		total += data[i];
	}

	median = total / num;
	total = 0;

	for (i = 0; i < num; i++)
		total += pow((data[i] - median), 2);
	return sqrt(total / num);
}

int main()
{
	int n;
	double sd;
	while (true)
	{
		cin >> n;
		if (!n) break;
		sd = standardDeviation(n);
		cout << fixed << setprecision(8);
		cout << sd << endl;
	}
}

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, k; cin >> a >> b >> c >> k;
    if(k&1) cout << -(a-b) << endl;
    else cout << a-b << endl;

    return 0;
}

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

const int INF = 1000000000;
struct edge{int from,to,cost;};
vector<edge> E;
int v,e,r;
int d[1000];

int main(){
  scanf("%d %d %d",&v,&e,&r);
  for(int i=0;i<e;i++){
    edge tmp;
    scanf("%d %d %d",&tmp.from,&tmp.to,&tmp.cost);
    E.push_back(tmp);
  }
  fill(d,d+v,INF);
  d[r] = 0;
  int count = 0;
  while(true){
    bool flag = true;
    for(int i=0;i<E.size();i++){
      if(d[E[i].from]!=INF&&d[E[i].from]+E[i].cost<d[E[i].to]){
        d[E[i].to] = d[E[i].from]+E[i].cost;
        flag = false;
      }
    }
    if(flag||count==v+5) break;
    count++;
  }
  if(count==v+5) printf("NEGATIVE CYCLE\n");
  else{
    for(int i=0;i<v;i++){
      if(d[i]==INF) printf("INF\n");
      else printf("%d\n",d[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 2788
#!/usr/bin/env python3

def main():
    n = int(input())
    s = input()
    print("".join([n_next_moji(c, n) for c in s]))

def n_next_moji(c, n):
    for i in range(n):
        c = next_moji(c)
    return c

def next_moji(c):
    if c == "Z":
        return "A"
    return chr(ord(c) + 1)

if __name__ == "__main__":
    main()


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

int main(){
	int n,ans=-1,count;

	cin >>n;
	int *array=new int[n];
	for(int i=0;i<n;i++)cin >>array[i];
	count=n;
	while(count==n){
		count=0;
		for(int i=0;i<n;i++){
			if(array[i]%2==0){
				array[i]/=2;
				count++;
			}
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<string, ll> cnt;
    rep(i, n){
        string s; cin >> s;
        cnt[s]++;
    }

    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
}

Measured memory_bytes: 3652
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        w: [chars; n],
    }
    let mut words = HashSet::new();
    for i in 0..n {
        words.insert(w[i].clone());
    }
    if words.len() != n {
        println!("No");
        return;
    }
    for i in 1..n {
        if w[i - 1][w[i - 1].len() - 1] != w[i][0] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

typedef struct linestruct{
  double a,b;
} line;

int cmpLine(const void *a,const void *b){
  double p=((line *)a)->a;
  double q=((line *)b)->a;
  return p-q>0?-1:1;
}

int calcInversion(double *a,int n,double *tmp){
  if(n<=1) return 0;
  int m=n/2;
  int res=calcInversion(a,m,tmp)+calcInversion(a+m,n-m,tmp);
  int i=0,j=m,k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      tmp[k++]=a[j++];
      res+=m-i;
    }
  }
  if(i<m) memcpy(tmp+k,a+i,sizeof(double)*(m-i));
  memcpy(a,tmp,sizeof(double)*(k+m-i));
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  line *l=(line *)calloc(n,sizeof(line));
  int i;
  for(i=0;i<n;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    l[i].a=-(double)a/b;
    l[i].b=(double)c/b;
  }
  qsort(l,n,sizeof(line),cmpLine);
  double *v=(double *)calloc(n,sizeof(double));
  double *tmp=(double *)calloc(n,sizeof(double));
  double ll=-200000000;
  double rr=200000000;
  for(int iter=0;iter<60;iter++){
    double m=(ll+rr)/2;
    for(i=0;i<n;i++) v[i]=l[i].a*m+l[i].b;
    int inv=calcInversion(v,n,tmp);
    if(2*inv<n*(n-1)/2){
      ll=m;
    } else {
      rr=m;
    }
  }
  double ansX=ll;
  for(i=0;i<n;i++){
    double a=l[i].a;
    double b=l[i].b;
    l[i]=(line){1/a,-b/a};
  }
  qsort(l,n,sizeof(line),cmpLine);
  ll=-200000000;
  rr=200000000;
  for(int iter=0;iter<60;iter++){
    double m=(ll+rr)/2;
    for(i=0;i<n;i++) v[i]=l[i].a*m+l[i].b;
    int inv=calcInversion(v,n,tmp);
    if(2*inv<n*(n-1)/2){
      ll=m;
    } else {
      rr=m;
    }
  }
  double ansY=ll;
  printf("%.9lf %.9lf\n",ansX,ansY);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2056
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		vector<int> cast(n);
		for (int i=0; i<n; i++) scanf("%d",&cast[i]);
		sort(cast.begin(), cast.end());
		long long res = 0;
		long long mati = 0;
		for (int i=0; i<n; i++) {
			res += mati;
			mati += cast[i];
		}
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n1, n2;
	vector< vector<int> > v;
	vector<int> v2, ans;
	cin >> n1 >> n2;

	for(int y = 0; y < n1; y++){
		vector<int> vTmp;
		for(int x = 0; x < n2; x++){
			int tmp;
			cin >> tmp;
			vTmp.push_back(tmp);
		}
		v.push_back(vTmp);
	}

	for(int i = 0; i < n2; i++){
		int tmp;
		cin >> tmp;
		v2.push_back(tmp);
	}

	for(int y = 0; y < n1; y++){
		int tmp = 0;
		for(int x = 0; x < n2; x++){
			tmp += v[y][x] * v2[x];
		}
		ans.push_back(tmp);
	}

	for(int i = 0; i < n1; i++){
		cout << ans[i] << '\n';
	}
}



Measured memory_bytes: 3136
N = int(input())
rate = list(map(int, input().split()))
rate.sort()

color = [False] * 9
i = rate[0] // 400
switch = 400 * (i + 1)

for r in range(len(rate)):
    if rate[r] < switch and i <= 7:
        color[i] = True
        if i == 8:
            color[8] += 1
    else:
        i = rate[r] // 400
        if i <= 7:
            color[i] = True
            switch = 400 * (i + 1)
        else:
            color[8] += 1

ans_min = sum(color[:8])
ans_max = sum(color)

if ans_min == 0:
    print("{} {}".format(1, ans_max))
else:
    print("{} {}".format(ans_min, ans_max))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef long long ll;
ll rec(int i,ll cur,ll sum,const string&S){
    if(i==S.size()){
        return sum;
    }
    int d=S[i]-'0';
    ll res=0;
    if(i+1!=S.size())
        res+=rec(i+1,cur*10+d,sum,S);
    res+=rec(i+1,0,sum+cur*10+d,S);
    return res;
}
int main(){
    string S;
    while (cin >>S)
    {
        ll ans=rec(0,0,0,S);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Text;
using CompLib.Util;

public class Program
{
    string abc = "abcdefghijklmnopqrstuvwxyz";

    public void Solve()
    {
        var sc = new Scanner();
        List<char> ans = new List<char>();
        long n = sc.NextLong();
        while (n > 0)
        {
            n--;
            ans.Add(abc[(int)(n%26)]);
            n /= 26;
        }


        ans.Reverse();

        Console.WriteLine(new string(ans.ToArray()));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc171/abc171_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  char N;
  cin >> N;

  cout << (N >= 'A' && N <= 'Z' ? 'A' : 'a') << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << (k * 500 >= x ? "Yes" : "No") << '\n';
    return 0;
}


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

int main()
{
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a + b >= c) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
	ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	for(int i = 0; i < N; ++i){
		ll big = D * i - C * (N - 1 - i);
		ll small = C * i - D * (N - 1 - i);
		if(A + small <= B && B <= A + big){
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long N;
  cin >> N;
  map<long,long> A;
  map<long,long> ap;
  vector<long> pe(N);
  for(long i=0;i<N;i++)
  {
    long B;
    cin >> B;
    pe.at(i)=B;
    if(A.count(B)){
      A.at(B)++;
    }
    else{
      A[B]=1;
    }
  }
  long wa=0;
  for(auto i=A.begin();i!=A.end();i++){
    long n=i->second;
    ap[i->first]=n*(n-3)/2+n;
    wa+=n*(n-3)/2+n;
  }
  for(auto i=ap.begin();i!=ap.end();i++){
    ap[i->first]=wa-i->second;
  }
  for(long k=0;k<N;k++){
    long ans = ap[pe[k]];
    long n = A[pe[k]]-1;
    ans+=n*(n-3)/2+n;
    cout << ans << endl;
  }
}
    

Measured memory_bytes: 18944
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var date = parseInt(line[0]);
    var length = parseInt(line[1]);
    var days = parseInt(line[2]);
    
    if(days>date+length){
        console.log("dangerous");
    } else if(days<=date+length && days>date){
        console.log("safe");
    } else {
        console.log("delicious");
    }
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    long first = A*B;
    long second = C*D;
    if(first>second){
        printf("%ld",first);
    }else{
        printf("%ld",second);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main() {
	long long int n,a,b,len,member=0,bmemo=1,s[100005];
	char str[100005];
	scanf("%lld%lld%lld%s", &n,&a,&b,str);
	len = strlen(str);
	for (int i = 0; i < len; i++) {
		if (str[i] == 'a'&&member < a + b) {
			member++;
			s[i] = 1;
		}
		if (str[i] == 'b'&&member < a + b && bmemo <= b) {
			member++;
			s[i] = 1;
			bmemo++;
		}
	}

	
	for (int i = 0; i < len; i++) {
		if (s[i]==1) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
}

Measured memory_bytes: 1408
N = int(input())
S = input()
C = set(list(S))
ans = 0

for i in range(1,N):
  A = 0
  X = S[:i]
  Y = S[i:]
  for j in C:
    if j in X and j in Y:
      A += 1
  ans = max(ans,A)
print(ans)
  

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int H, W;
ll MOD = 1e9+7;
char a[1003][1003];
ll DP[1003][1003];

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

  cin >> H >> W;
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }
  
  DP[0][0] = 1;
  rep(i, H) {
    rep(j, W) {
      if (i+1 < H && a[i+1][j]=='.') {
        DP[i+1][j]+=DP[i][j];
        DP[i+1][j]%=MOD;
      }
      if (j+1 < W && a[i][j+1]=='.') {
        DP[i][j+1]+=DP[i][j];
        DP[i][j+1]%=MOD;
      }
    }
  }
  
  cout << DP[H-1][W-1] << "\n";
  return 0;
}

Measured memory_bytes: 9088
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;
const int mod=1e9+7;

int n,m,cnt,top;
int a[N],b[N],S[N];
pair<int,int> p[N];
int f[N];

inline int cmp(pair<int,int> a,pair<int,int> b) {
    if (a.first!=b.first) return a.first<b.first;
    else return a.second>b.second;
}

int c[N];
inline int lowbit(int x) { return x&-x; }
inline int query(int x) { int res=0;
    for (;x;x-=lowbit(x)) res=(res+c[x])%mod;
    return res;
}
inline void add(int x,int y) {
    for (;x<=top;x+=lowbit(x)) c[x]=(c[x]+y)%mod;
}

int main() {
    n=read(),m=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    for (re int i=1;i<=m;++i) b[i]=read();
    for (re int i=1;i<=n;++i) {
        if (a[i]<=b[1]||a[i]>=b[m]) continue;
        int x=lower_bound(b+1,b+m+1,a[i])-b;
        if (b[x]==a[i]) continue;
        p[++cnt]=make_pair(a[i]-b[x-1],b[x]-a[i]);
        S[++top]=b[x]-a[i];
    }
    sort(S+1,S+top+1); top=unique(S+1,S+top+1)-S-1;
    for (re int i=1;i<=cnt;++i)
        p[i].second=lower_bound(S+1,S+top+1,p[i].second)-S;
    sort(p+1,p+cnt+1,cmp); cnt=unique(p+1,p+cnt+1)-p-1;
    f[0]=1;
    for (re int i=1;i<=cnt;++i)
        f[i]=query(p[i].second-1)+1,add(p[i].second,f[i]);
    int ans=0;
    for (re int i=0;i<=cnt;++i) ans=(ans+f[i])%mod;
    printf("%d\n",ans);
    return 0;
}
//qwq

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

int main() {
	int n;
	set<char> s;
	cin >> n;
	rep(i, n) {
		char tmp;
		cin >> tmp;
		s.insert(tmp);
	}
	if(s.size()==3) puts("Three");
	else puts("Four");
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	struct info{
		int x;
		int y;
		long long int h;
	};
	vector<info> infos(n);
	for(int i = 0; i < n; i++)
	{
		int x, y, h;
		cin >> x >> y >> h;
		info temp = {x, y, h};
		infos[i] = temp;
	}
	for(int cx = 0; cx <= 100; cx++)
	{
		for(int cy = 0; cy <= 100; cy++)
		{
			long long int h = -1;
			long long int upper = -1;
			bool flag = true;
			for(int i = 0; i < n; i++)
			{
				if(infos[i].h == 0)
				{
					long long int temp = abs(infos[i].x - cx) + abs(infos[i].y - cy);
					if(upper == -1)
					{
						upper = temp;
					}else{
						upper = min(upper, temp);
					}
				}else{
					long long int temp = infos[i].h + abs(infos[i].x - cx) + abs(infos[i].y - cy);
					if(h == -1 || h == temp)
					{
						h = temp;
					}else{
						flag = false;
						break;
					}
				}
			}
			if(flag)
			{
				if(upper == -1 || h <= upper)
				{
					cout << cx << " " << cy << " " << h << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Restaurant implements Comparable<Restaurant> {
	String city;
	int point;
	int i;

	public Restaurant(String city, int point, int i) {
		this.city = city;
		this.point = point;
		this.i = i;
	}

	public int compareTo(Restaurant other) {
		int ans = city.compareTo(other.city);
		if (ans != 0)
			return ans;
		return Integer.compare(other.point, point);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Restaurant> list = new ArrayList<Restaurant>();
		int n = sc.nextInt();

		for (int i = 1; i <= n; i++) {
			String city = sc.next();
			int point = sc.nextInt();
			list.add(new Restaurant(city, point, i));
		}

		Collections.sort(list);

		for (Restaurant restaulant : list) {
			System.out.println(restaulant.i);
		}
	}
}

Measured memory_bytes: 35884
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;
     //int g[105][105];
    //vector < int > wt(100004);
   // vector < int > a;
    //vector < int > v(30500);
    //int cst[102][100005];
    //int ansr[100005];
 //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;
    //vector < vector < int > > adj(5000, vector < int > (5000));
 //int  dp[1000006];
   // int level[500];




    void solve()
    {
        long long int i,j=0,r=200,p,q,k=0,ans=0,d,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
         cin>>n;
         vector <ll int > v(n),dp(n,hell);
         rep(i,0,n)
         {
             cin>>v[i];
         }
         dp[0]=0; dp[1]=abs(v[1]-v[0]);
         rep(i,2,n)
            {
                dp[i]=min(dp[i],min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i])));
            }
            cout<<dp[n-1];



    }



    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }

       /*

  void bfs( int i , int j)
       {
           vis[i][j]= true;
         queue < int > que;
         que.push(k);
         while(!que.empty())
         {
            int x= que.front();
            que.pop();
             for ( int i=1;i<=n;i++)
             {
                 if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                 {
                   if(!vis[i])
                   {
                       que.push(i);
                       level[i]=level[x]+1;
                       vis[i]= true;
                   }
                 }
             }
         }
       }

      ll int por(ll int a,ll int b)
         {
            ll int k=1;
            while(b>0)
            {
                if(b%2) k=k*a,k%=hell;
                b/=2;
                a*=a; a%=hell;
            }
            return k;
         } */


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

int main() {
	string s;
	int i, count = 1,j,x;
	cin >> s;
	for (i = 0;i < s.size();++i)if (s[i] == 'A')break;
	for (j = 0;j < s.size();++j)if (s[j] == 'Z') {
		x = j;
		continue;
	}
	cout << x-i+1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int N=100010;
int main()
{
  struct Point {LL x, y;};
  LL N;
  cin >> N;
  vector<Point> P(N);
  for(auto& p: P) cin >> p.x >> p.y;

  auto parity = abs(P[0].x+P[0].y)&1;
  for(const auto& p: P) if((abs(p.x+p.y)&1) != parity) {
    cout << -1 << endl;
    exit(0);
  }

  auto m = 31ll;
  vector<LL> d;
  for(auto i=m-1; 0<=i; --i) d.emplace_back(1ll<<i);
  if(!parity) d.emplace_back(1ll), ++m;

  cout << m << endl;
  for(auto i: d) cout << (i==d.front() ? "" : " ") << i;
  cout << endl;
  for(const auto& p: P) {
    auto x = p.x;
    auto y = p.y;
    for(auto i: d) {
      if(abs(x)<abs(y)) {
        if(y<0) {y += i; cout << "D";}
        else    {y -= i; cout << "U";}
      } else {
        if(x<0) {x += i; cout << "L";}
        else    {x -= i; cout << "R";}
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    rep(i, 0, N) cin >> a[i] >> b[i];
    rep(i, 0, M) cin >> c[i] >> d[i];
    rep(i, 0, N)
    {
        int nearestPoint = -1;
        int minDist = INT_MAX;
        rep(j, 0, M)
        {
            const int dist = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (chmin(minDist, dist))
            {
                nearestPoint = j + 1;
            }
        }
        cout << nearestPoint << endl;
    }
}


Measured memory_bytes: 256
def partition(a, p, r):
    q  = p
    for i in range(p, r):
        if a[i] <= a[r]:
            a[q], a[i] = a[i], a[q]
            q += 1
    a[q], a[r] = a[r], a[q]
    return q 

n = input()
a = list(map(int, input().split()))
q = partition(a, 0, len(a) - 1)
a[q] = '[{}]'.format(a[q])
print(*a)

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

namespace AtCoder.DP
{
    class EDPC_V
    {
        public class Node
        {
            public int Parent;
            public List<int> Next;
            public Node()
            {
                Next = new List<int>();
            }
        }

        public static int[] SortTree(int root, Node[] nodes)
        {
            int[] sorted = new int[nodes.Length];
            var queue = new Queue<int>();
            queue.Enqueue(root);
            int count = 0;
            while (queue.Any())
            {
                var i = queue.Dequeue();
                sorted[count++] = i;
                foreach (var next in nodes[i].Next)
                {
                    nodes[next].Next.Remove(i);
                    queue.Enqueue(next);
                }
            }
            return sorted;
        }

        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nm[0];
            var m = nm[1];
            if (n == 1)
            {
                Console.WriteLine(1);
                return;
            }

            var nodes = new Node[n];
            for (int i = 0; i < n; i++)
                nodes[i] = new Node();

            for (int i = 0; i < n - 1; i++)
            {
                var xy = Console.ReadLine().Split(' ').Select(j => int.Parse(j) - 1).ToArray();
                nodes[xy[0]].Next.Add(xy[1]);
                nodes[xy[1]].Next.Add(xy[0]);
            }

            var sortedIndex = SortTree(0, nodes); // メモ化再帰だとStackOverflowの可能性

            var dpf = new long[n]; // Forward
            for (int i = n - 1; i >= 0; i--)
            {
                int j = sortedIndex[i];
                dpf[j] = 1;
                if (nodes[j].Next.Count == 0)
                    continue;
                foreach (var next in nodes[j].Next)
                    dpf[j] = dpf[j] * (dpf[next] + 1) % m;
            }

            var cumprodL = new long[n + 2];
            var cumprodR = new long[n + 2];
            var dpr = new long[n]; // Reverse
            dpr[0] = 1;
            for (int i = 0; i < n; i++)
            {
                int j = sortedIndex[i];
                var next = nodes[j].Next;

                cumprodL[0] = 1;
                cumprodR[next.Count] = 1;
                for (int l = 0; l < next.Count; l++)
                {
                    int r = next.Count - l;
                    cumprodL[l + 1] = cumprodL[l] * (dpf[next[l]] + 1) % m;
                    cumprodR[r - 1] = cumprodR[r] * (dpf[next[r - 1]] + 1) % m;
                }

                for (int k = 0; k < next.Count; k++)
                    if (next[k] != nodes[j].Parent)
                        dpr[next[k]] = (cumprodL[k] * cumprodR[k + 1] % m * dpr[j] + 1) % m;
            }

            Console.WriteLine(dpf[0]);
            for (int i = 1; i < n; i++)
                Console.WriteLine(dpf[i] * dpr[i] % m);
        }
    }
}

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

int main() {
  char c;
  string judge;
  
  cin >> c;
  switch(c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    judge = "vowel";
    break;
  default:
    judge = "consonant";
    break;
  }

  cout << judge << endl;
  return 0;
}


Measured memory_bytes: 256
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int t=1;
  //cin>>t;
    while(t--){
            int n,flag=1;
    cin>>n;
    int t[n],x[n],y[n];
    cin>>t[0]>>x[0]>>y[0];
    int i;
    i=0;
    if(n==1)
    {
        int dis=abs(x[i])+abs(y[i]);
        if((dis+t[i])&1)
            flag=0;
        else if(dis>t[i])
            flag=0;
    }
    fr(i,1,n)
    {
        cin>>t[i]>>x[i]>>y[i];
        if(flag==0)
            continue;
        int dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if((dis+t[i]-t[i-1])&1)
            flag=0;
        else if(dis>t[i]-t[i-1])
            flag=0;
    }
    if(flag==0)
        cout<<"No";
    else
        cout<<"Yes";

  }
  return 0;
  }



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


#define min(a,b) ((a)<(b)?(a):(b))

int cmp_int(const void *a, const void *b) {
    if (*(int*)a < *(int*)b) {
        return -1;
    }
    else if (*(int*)a > *(int*)b) {
        return 1;
    }
    return 0;
}

int shop[100001];

int main(void) {
    int d, n, m, k, i, l, r, c;
    int total, dist;
    while (scanf("%d", &d) != EOF && d) {
        scanf("%d\n", &n);
        scanf("%d\n", &m);
        shop[0] = 0;
        for (i = 1; i < n; i++) {
            scanf("%d", &shop[i]);
        }
        shop[n] = d;
        qsort(shop, n+1, sizeof(int), cmp_int);

        for (i = 0, total = 0;
             i < m; i++) {
            scanf("%d", &k);
            for (l = 0, r = n+1;;) {
                c = (l + r) / 2;
                if (shop[c] == k) {
                    dist = 0;
                    break;
                }
                else if (r - l <= 1) {
                    dist = abs(shop[c]-k);
                    if (c > 0) dist = min(abs(shop[c-1]-k), dist);
                    if (c < n) dist = min(abs(shop[c+1]-k), dist);
                    break;
                }
                if (k < shop[c]) {
                    r = c;
                }
                else {
                    l = c + 1;
                }
            }
            total += dist;
        }
        printf("%d\n", total);
    }


    return 0;
}

Measured memory_bytes: 1424