akhauriyash/Code-Regression huggingface dataset:
use std::io;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut vec = Vec::new();
    for _ in 0..h {
        let chr: Vec<char> = read_one::<String>()
            .chars().collect();
        vec.push(chr);
    }

    let mut flg = true;
    for j in 0..h { for k in 0..w {
        if vec[j][k] == '#' {
            let mut f = false;
            if 0 < j && vec[j - 1][k] == '#' { f = true; }
            if 0 < k && vec[j][k - 1] == '#' { f = true; }
            if j < h - 1 && vec[j + 1][k] == '#' { f = true; }
            if k < w - 1 && vec[j][k + 1] == '#' { f = true; }
            if !f { flg = false; break; }
        }
    }}

    if flg {
        println!("Yes");
    } else {
        println!("No"); 
    }
}

Measured memory_bytes: 4352
#include<stdio.h>

#define N 1000000

int main(){
  int n,q,C=0;
  int S[N],T[N];
  int i,j,key;
  int l,m,r;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  S[n]=-1;
  for(i=0;i<q;i++){
    l=0;
    r=n;
    key=T[i];
    if(S[n]==T[i])continue;
    S[n]=key;
    while(l<r){
      m=(l+r)/2;
      if(S[m] == key){
	C++;
	break;
      }
      else if(key<S[m])r=m;
      else l=m+1;
    }
  }

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

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

int main() {
  int64_t n;
  cin >> n;
  string name ="";//英小文字
  while(n) {
    n--;
    name += (char)('a' + n % 26LL);
    n /= 26LL;
  }
  reverse(name.begin(), name.end());
  cout << name;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, K;
int A[MAX_N];

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

  cin >> N >> K;
  REP(i, N) cin >> A[i];

  map<int, int> mp;
  REP(i, N) { mp[A[i]]++; }

  if (mp.size() <= K) {
    cout << 0 << endl;
    return 0;
  }

  priority_queue<int, vector<int>, greater<int>> q;
  for (auto m : mp) {
    q.push(m.second);
  }

  int ans = 0;
  int sum = mp.size();
  while (!q.empty() && sum > K) {
    int n = q.top();
    q.pop();
    sum--;
    ans += n;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11512
/*
 * Problem: Prime Numbers
 * Author: Khan
 * Date: 11th October, 2017
 */
#include <iostream>

using namespace std;

int bubbleSort(int A[], int N)
{
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; ++i)
    {
        flag = 0;
        for (int j = N - 1; j >= i + 1; --j)
        {
            if(A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(int argc, char const *argv[])
{
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; ++i)
    {
        if(i)
            cout << " ";
        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

long long gcd(long long a, long long b) {
    if (a < b) {
        std::swap(a, b);
    }
    while (a%b > 0) {
        long long buf = b;
        b = a%b;
        a = buf;
    }
    return b;
}

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


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int jewelNum;
    cin >> jewelNum;
    
    int value[jewelNum], cost[jewelNum];
    for(int i = 0; i < jewelNum; i++) cin >> value[i];
    for(int i = 0; i < jewelNum; i++) cin >> cost[i];
    
    int total = 0;
    for(int i = 0; i < jewelNum; i++){
        if(cost[i] >= value[i]) continue;
        total += value[i] - cost[i];
    }
    
    cout << total;
    
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a =  list(map(int,input().split()))
dp = [[0]*2 for i in range(n+1)]
dp[0][0] = 0
INF = -10**9
dp[0][1] = INF
for i in range(n):
    dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i])
    dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i])
print(dp[n][0])


Measured memory_bytes: 25580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int n, k;

bool C(vector<int> a, double x) {
  int kaisuu = 0;
  for (int el : a) kaisuu += (el - 1) / x;
  return kaisuu <= k;
}

int main() {
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  double lb = 0, ub = INF;

  for (int i = 0; i < 100; i++) {
    double mid = (lb + ub) / 2;
    if (C(a, mid))
      ub = mid;
    else
      lb = mid;
  }

  cout << (int)(floor(lb) + 1) << endl;
  return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	while (cin >> s) {
		int lens = (int)s.length();
		for (int i = 0; i < lens; ++i)
			if (i % 2 == 0) cout << s[i];
		cout << endl;
	}
	return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line
//グラフ問題のテンプレ
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> > ;
int N ;
Graph G;

vector<int> res;

//vは現在見ている頂点。pはvの親
void dfs(int v, int p, int c) {
	res[v] = c;
	for (auto e : G[v]) {
		if(e.first == p) continue;
		if(e.second & 1) dfs(e.first, v, 1-c);
		else dfs(e.first, v, c);
	}
}

int main() {
	cin >> N ;
	G.assign(N, vector<Edge>() );
	for(int i = 0 ; i < N - 1 ; i++){
		int u, v, w;
		cin >> u>> v>> w;
		u-- ; v --;
		G[u].push_back(Edge(v,w));
		G[v].push_back(Edge(u,w));
	}
	res.assign(N,0);
	dfs(0,-1,1);
	for ( auto v : res) cout << v << endl;
}


Measured memory_bytes: 8960
#include <stdio.h>
#define max 200000

int main ()
{
    int n;
    int i;
    int x;
    int min=max+1;
    int count=0;
    scanf("%d",&n);

    int num[n];

    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        num[i]=x;

        if(x<min)
        {
            min=x;
            count++;
        }
    }

    printf("%d",count);

    return 0;

}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

#define ll long long
const ll  modu = 1e9 + 7;
using namespace std;

//int gcd(int a, int b) {
//	return b == 0 ? a : gcd(b, a % b);
//}
//
//int lcm(int a, int b) {
//	return a * b / gcd(a, b);
//}
//
//bool comp(vector<int> a, vector<int> b)
//{
//	return a[2] < b[2];
//}
//bool isPal(string s)
//{
//	int start = 0; int end = s.size() - 1;
//	while (start < end)
//	{
//		if (s[start] != s[end]) return false;
//		start++;
//		end--;
//	}
//	return true;
//}
////s && l
////bool comp(vector<int> v1, vector<int> v2)
////{
////	return v1[0] < v2[0];
////}
void a()
{
	int n; cin >> n;
	vector<int> num(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> num[i];
		sum += num[i];
	}

	double aver = 1.0 * sum / n;
	int ret = 0;
	for (int i = 1; i < n; i++)
	{
		if (fabs(1.0 * num[i] - aver) < fabs(1.0 * num[ret] - aver))
			ret = i;
	}
	cout << ret;
}
int main()
{
	a();

	return 0;
}


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			while(true) {
				String str = br.readLine();
				int N = Integer.parseInt(str);
				if(N == 0) break;
				int a = 0;
				int b = 0;
				for(int i = 0; i < N;i++) {
					str = br.readLine();
					String[] s = str.split(" ", 0);
					int aa = Integer.parseInt(s[0]);
					int bb = Integer.parseInt(s[1]);
					if(aa > bb) {
						a += (aa + bb);
					}else if (aa < bb) {
						b += (aa + bb);
					}else {
						a += aa;
						b += bb;
					}
				}
				System.out.println(a+" "+b);
			}

		}catch (Exception e) {
			System.exit(0);
		}
	}
}

Measured memory_bytes: 34708
arg = input().split(' ')
w = int(arg[0])
a = int(arg[1])
b = int(arg[2])

res = 0

if a <= b <= a + w or a <= b + w <= a + w:
  res = 0
else:
  res = min(abs(b - (a + w)), abs(a - (b + w)))

print(res)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

 class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        if (c > b) {
            System.out.println(0);
        } else if (a > d) {
            System.out.println(0);
        } else if (a < c) {
            System.out.println(Math.min(b, d) - c);
        } else {
            List<Integer> l = new ArrayList<>();
            l.add(a);
            l.add(b);
            l.add(c);
            l.add(d);
            Collections.sort(l);
            System.out.println(l.get(2) - l.get(1));
        }
    }

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

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

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

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

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

    }
}


Measured memory_bytes: 22356
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = (max(xs), min(ys))
ans = "War"
if zs[0] < zs[1]:
  if x < zs[0] and zs[0] < y:
    ans = 'No War'
  if x < zs[1] and zs[1] <= y:
    ans = 'No War'
print(ans)


Measured memory_bytes: 3064
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
//inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for(int& x : a)
        cin >> x;

    int ans = 0;

    for (int i = 1; i + 1 < n; ++i) {
        ans += a[i] > a[i - 1] && a[i] < a[i + 1];
        ans += a[i] < a[i - 1] && a[i] > a[i + 1];
    }
    cout << ans << endl;
}


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

int main() {
    int K;
    string S;

    cin >> K >> S;

    int L = S.length();

    if (K >= L){
        cout << S << endl;
    }
    else
    {
        for (int i=0;i<K;i++){
            cout << S.at(i);
        }
            cout << "..." << endl;
    }
    

}


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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    ll A, B;

    cin >> A >> B;

    cout << (A + B < 10 ? to_string(A + B) : "error") << endl;

    return 0;
}

Measured memory_bytes: 256
import math
A, B = map(int, input().split())
rate8max = math.floor((A+1)/0.08)
rate8min = math.ceil(A/0.08)
rate10max = math.floor((B+0.9)/0.1)
rate10min = math.ceil(B/0.1)
ans = -1
if rate10min >= rate8min and rate10min <= rate8max:
    for i in range(rate10min, rate8max+1):
        if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
            ans = i
            break
elif rate8min >= rate10min and rate8min <= rate10max:
    for i in range(rate8min, rate10max+1):
        if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
            ans = i
            break
    # 100            100          109         112
elif rate10min >= rate8min and rate10max <= rate8max:
    for i in range(rate10min, rate10max+1):
        if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
            ans = i
            break
elif rate8min >= rate10min and rate8max <= rate10max:
    for i in range(rate8min, rate8max+1):
        if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
            ans = i
            break
print(ans)


Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();
        
        if ((A1+A2+A3) >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    
    }
}

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

int N;
struct Data{
  int n;
  int w;
};
vector<Data> B[1000000];
int C[1000000];

void update(int n){
  for(auto b:B[n]){
    if(C[b.n]<0){
      if(b.w%2==0) C[b.n]=C[n];
      else         C[b.n]=(C[n]+1)%2;
      update(b.n);
    }
  }
}

int main(void){
  cin>>N;
  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    Data d; d.w=w;
    d.n=v-1;
    B[u-1].push_back(d);
    d.n=u-1;
    B[v-1].push_back(d);
  }
  for(int i=0;i<N;i++) C[i]=-1;
  C[0]=0;
  update(0);
  for(int i=0;i<N;i++) cout<<C[i]<<endl;
  return 0;
}


Measured memory_bytes: 30592
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 2004;
int dp[N][N]; // (idx, min from the front)
const int mod = 1000000007;
void adding(int &a, int b){ if((a+=b)>=mod) a -= mod; }
int add(int a, int b){ return (a+=b)>=mod ? a-mod : a; }
int mul(int a, int b){ return a * 1ll * b % mod; }
void solve(){
    int n, k;
    scanf("%d %d",&n,&k);
    FOR(i, 2, n) dp[1][i] = 1;
    FOR(i, 2, k-1){
        FOR(j, 2, n){
            adding(dp[i][2], dp[i-1][j]);
            adding(dp[i][j], mod-dp[i-1][j]);
        }
        FOR(j, 2, n){
            adding(dp[i][j], dp[i][j-1]);
        }
        FOR(j, 2, n-i+1){
            adding(dp[i][j], dp[i-1][j]);
        }
    }
    int ans = 0;
    FOR(i, 2, n) adding(ans, dp[k-1][i]);
    if(k == 1) ans = 1;
    FOR(i, 1, n-k-1) ans = mul(ans, 2);
    printf("%d",ans);
}

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

Measured memory_bytes: 19424
import java.util.*;
import java.io.*;
public class Main extends PrintWriter {
    Main()
    {
        super(System.out);
    }
    public static void main(String args[]) {
      Main o=new Main();
      o.main();
      o.flush();
      o.close();
    }
    void main()
    {
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        if(x>=30)
        println("Yes");
        else
        println("No");
        sc.close();
    }
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string s, t;
vector<string> v;

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

    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        bool match = true;
        for (int j = 0; j < t.size(); j++) {
            if (t[j] != s[i+j] && s[i+j] != '?') {
                match = false;
                break;
            }
        }

        if (match) {
            string u(s);
            for (int j = 0; j < t.size(); j++) u[i+j] = t[j];
            for (int k = 0; k < u.size(); k++) {
                if (u[k] == '?') u[k] = 'a';
            }
            v.emplace_back(u);
        }
    }
    if (v.empty()) cout << "UNRESTORABLE" << endl;
    else {
        sort(v.begin(), v.end());
        cout << v[0] << endl;
    }
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Bismillahirrahmanirrahim
#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k,mx=-inf;
string s;
vector<int> v;

int main(){
	fio();
	cin>>s;
	for(int i=0;i<(int)s.size();i++){
		mx=max(cev,mx);
		if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){cev++;mx=max(cev,mx);}
		else{mx=max(cev,mx);cev=0;}
		mx=max(cev,mx);
	}
	printf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h) {
        rep(j,w) {
        cin >> s.at(i).at(j);
        }
    }

    int res = 0;
    vector<vector<int>> l(h,vector<int>(w));
    vector<vector<int>> r(h,vector<int>(w));
    vector<vector<int>> d(h,vector<int>(w));
    vector<vector<int>> u(h,vector<int>(w));
    rep(i,h) {
        int cur = 0;
        rep(j,w) {
            if ( s.at(i).at(j) == '#') cur = 0;
            else ++cur;
            l.at(i).at(j) = cur;
        }
    }

    for ( int i = 0 ; i < h ; ++i ) {
        int cur = 0 ;
        for ( int j = w-1; j >= 0;--j) {
            if ( s.at(i).at(j) == '#' ) cur = 0;
            else ++cur ;
            r.at(i).at(j) = cur;
        }
    }
    
    for (int j = 0 ; j < w; ++j) {
        int cur = 0;
        for (int i = 0; i < h ; ++i) {
            if ( s.at(i).at(j) == '#') cur = 0;
            else ++cur;
            u.at(i).at(j) = cur;
        }
    }

    for ( int j = 0; j < w ; ++j) {
        int cur = 0;
        for (int i = h-1; i >= 0;--i) {
            if ( s.at(i).at(j) == '#') cur = 0;
            else ++cur;
            d.at(i).at(j) = cur;
        }
    }

    rep(i,h) {
        rep(j,w) {
            if ( s.at(i).at(j) == '#' ) continue;
            res = max(res,l.at(i).at(j)+r.at(i).at(j)+u.at(i).at(j)+d.at(i).at(j)-3);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 67072
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
ll x[MAXN],dif[MAXN],tdif[MAXN],dp[MAXN][70],ind[MAXN],tind[MAXN],n,m,k;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&x[i]);
    scanf("%lld %lld",&m,&k);
    for(int i=1;i<=n;++i) dp[i][0]=i;
    for(int i=1;i<=m;++i){
        ll t;scanf("%lld",&t);
        swap(dp[t][0],dp[t+1][0]);
    }
    for(int j=1;((ll)1<<j)<=k;++j){
        for(int i=1;i<=n;++i){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
    for(int i=1;i<=n;++i) ind[i]=i;
    for(int j=62;k;--j){
        if(((ll)1<<j)>k) continue;
        k-=(ll)1<<j;
        for(int i=1;i<=n;++i){
            tind[i]=dp[ind[i]][j];
        }
        for(int i=1;i<=n;++i) ind[i]=tind[i];
    }
    dif[1]=x[1];
    for(int i=2;i<=n;++i) dif[i]=x[i]-x[i-1];
    for(int i=1;i<=n;++i) tdif[i]=dif[ind[i]];
    for(int i=2;i<=n;++i) tdif[i]+=tdif[i-1];
    for(int i=1;i<=n;++i) printf("%lld\n",tdif[i]);
    return 0;
}

Measured memory_bytes: 59904
#include <iostream>
using namespace std;
int gcd(int a, int b) {
    return b>0?gcd(b,a%b):a;
}
int D[220][220];
int N,ans;
int main() {
    cin >> N;
    for(int x=1; x<=N; x++) {
        for(int y=x; y<=N; y++) {
            int ret = gcd(x,y);
            D[x][y] = ret;
            D[y][x] = ret;
        }
    }
    for(int x=1; x<=N; x++) {
        for(int y=1; y<=N; y++) {
            for(int z=1; z<=N; z++) {
                ans += D[D[x][y]][z];
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3792
n =gets.to_i
l0 = 2
l1 = 1
l2 = 0
if n == 1
  puts 1
else
  2.upto(n) do |i|
    l2 = l0 + l1
    l0 = l1
    l1 = l2
  end
  puts l2
end

  

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans=1,n,m;
    cin>>n>>m;
    vector<pair<int,int> > ba;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        ba.push_back(make_pair(b,a));
    }
    sort(ba.begin(),ba.end());
    int x=ba[0].first-1;
    for(int i=0;i<m;i++){
        if(ba[i].second<=x)continue;
        else {
            ans++;
            x=ba[i].first-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define vi vector<int>
#define pi pair<int,int>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ll long long 

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
	int add(int a,int b)
	{
		a+=b;
		if(a>=mod)return a-mod;
		return a;
		}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
		return res;
	}



void solve()
{
int n,W;
cin>>n>>W;
ll dp[100001];
for(int i=0;i<100001;i++)dp[i]=1e18+5;
dp[0]=0;
int sum=0;
for(int i=0;i<n;i++)
{
	int w,v;
	cin>>w>>v;
	sum+=w;
	for(int j=100000;j>=v;j--)
	{
		dp[j]=min(dp[j],dp[j-v]+w);
		}
	
	}
	ll ans=0;
for(int i=0;i<=100000;i++){if(dp[i]<=W)ans=i;}
cout<<ans;
}
	
	
int main()
{   ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		}
	
	
	}


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



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    vector<int> vec(3);
    vec={a+b,b+c,c+a};
    sort(vec.begin(),vec.end());
    
    cout << vec.at(0) << endl;
    
   
}
    

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	vector<int> a(26);
	string s;
	while (getline(cin, s)) {
		for (int i = 0; i < s.length(); i++)
			if (s[i] >= 'A' && s[i] <= 'Z') a[s[i] - 'A']++;
			else if (s[i] >= 'a' && s[i] <= 'z') a[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++)
		cout << (char)('a' + i) << " : " << a[i] << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int b;
            cin >> b;
            a[b-1]++; 
        }
    }
    int ans = 0;
    rep(i,m){
        if(a[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n;
  cin>>n;
  cout<<180*(n-2)<<endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int dp[3001][3001];
int n;
string s;

void solve() {
	dp[n][0] = (s[n - 2] == '>') ? 1 : 0;
	dp[n][1] = (s[n - 2] == '<') ? 1 : 0;
	for (int i = n - 1; i >= 2; i--) {
		int total = n - i + 1;
		for (int g = 0; g <= total; g++) {
			if (g == 0) {
				if (i == n)continue;
				dp[i][g] = 0;
				if (s[i - 2] == '<') continue;
				for (int j = 1; j <= total; j++) {
					dp[i][g] = (dp[i][g] + dp[i + 1][total - j]) % mod;
				}
			} else {
				if (s[i - 2] == '>') {
					dp[i][g] = (mod + dp[i][g - 1] - dp[i + 1][g - 1]) % mod;
				} else {
					dp[i][g] = (dp[i][g - 1] + dp[i + 1][g - 1]) % mod;
				}
			}
		}
	}
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;
	cin >> s;

	solve();

	int ans = 0;

	for (int g = n - 1; g >= 0; g--) {
		ans = ans + dp[2][g];
		if (ans >= mod)ans -= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 49652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        
        int[] r = new int[n];
        int[] g = new int[n];
        int[] b = new int[n];
        for(int i = n-1; i >= 0; i--){
            if(i != n-1){
                r[i] = r[i+1];
                g[i] = g[i+1];
                b[i] = b[i+1];
            }
            switch(s.charAt(i)){
                case 'R':
                    r[i]++;
                    break;
                case 'G':
                    g[i]++;
                    break;
                case 'B':
                    b[i]++;
                    break;
            }
        }
        
        long ans = 0;
        for(int i = 0; i < n-2; i++){
            for(int j = i+1; j < n-1; j++){
                int k = j + (j-i);
                if(s.charAt(i) == 'R'){
                    if(s.charAt(j) == 'G'){
                        ans += b[j+1];
                        if(k < n && s.charAt(k) == 'B'){
                            ans--;
                        }
                    }else if(s.charAt(j) == 'B'){
                        ans += g[j+1];
                        if(k < n && s.charAt(k) == 'G'){
                            ans--;
                        }
                    }
                }else if(s.charAt(i) == 'G'){
                    if(s.charAt(j) == 'R'){
                        ans += b[j+1];
                        if(k < n && s.charAt(k) == 'B'){
                            ans--;
                        }
                    }else if(s.charAt(j) == 'B'){
                        ans += r[j+1];
                        if(k < n && s.charAt(k) == 'R'){
                            ans--;
                        }
                    }
                }else{
                    if(s.charAt(j) == 'R'){
                        ans += g[j+1];
                        if(k < n && s.charAt(k) == 'G'){
                            ans--;
                        }
                    }else if(s.charAt(j) == 'G'){
                        ans += r[j+1];
                        if(k < n && s.charAt(k) == 'R'){
                            ans--;
                        }
                    }
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 28364
#include<stdio.h>

int main(){
  int a,b,c,x;
  x=0;
  scanf("%d%d%d",&a,&b,&c);
  while(a<=b){
    if(c%a==0){
      x = x+1;}
    a = a+1;}
  printf("%d\n",x);
  return 0;}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const int inf = int(1e10);
//const ll inf = ll(1e19);
const int mod = int(1e9) + 7;

int h, n, ab[1001][2];
int dp[10001];
int main(){
    cin >> h >> n;
    rep(i, n){
        int a, b; cin >> a >> b;
        ab[i][0] = a;
        ab[i][1] = b;
    }
    rep(i, 10001) dp[i] = inf;
    dp[0] = 0;
    rep(i, h){
        if(dp[i] == inf) continue;
        rep(j, n){
            if(i + ab[j][0] <= h)
            dp[i + ab[j][0]] = min(dp[i + ab[j][0]], dp[i] + ab[j][1]);
            else
            dp[h] = min(dp[h], dp[i] + ab[j][1]);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string str;
  int k;
  cin >> str >> k;
  int n = str.size();
  vector<string> a;
  rep(i,n) {
    string res = "";
    res += str[i];
    a.emplace_back(res);
    for (int j = i+1; j < i+5 && j < n; ++j) {
      res += str[j];
      a.emplace_back(res);
    }
  }
  sort(all(a));
  a.erase(unique(all(a)), a.end());
  cout << a[k-1] << endl;
  return 0;
}

Measured memory_bytes: 1660
sx,sy,tx,ty = gets.chomp.split.map(&:to_i)
dx = tx - sx
dy = ty - sy
ans = "U" * dy + "R" * dx + "D" * dy + "L" * (dx+1) + "U" * (dy+1) + "R" * (dx+1) + "DR" + "D" * (dy+1) + "L" * (dx+1) + "U"
puts ans

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

using namespace std;


typedef long long ll;


int main()
{
    //freopen("", "r", stdin);freopen("", "w", stdout);
    char c;
    cin>>c;
    if (c=='A'){
        cout<<'T';
        return 0;
    }
    if (c=='T'){
        cout<<'A';
        return 0;
    }
    if (c=='C'){
        cout<<'G';
        return 0;
    }
    if (c=='G'){
        cout<<'C';
        return 0;
    }
    return 0;
}


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

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

  int n;
  cin >> n;
  
  int sn = 0;
  int num = n;
  while(num != 0){
    sn += num % 10;
    num /= 10;
  }
  
  if(n % sn == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string S,T;
    cin >> S >> T;
    T.pop_back();
    cout << ((S==T)?"Yes":"No") << endl;
}


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

using namespace std;
#define ll long long int
#define ed "\n"


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,sum=0,count=0,i=0,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3==0 ||i%5 == 0||(i%3==0 && i%5==0))
		{
			continue;
		}
		sum+=i;
		
	}
	
	
	cout<<sum<<ed;
	return 0;
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 3652
#pragma region def
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
using pint = pair<int, int>;
const int INF = 1e9;
const long long llINF = 1e18;
#pragma endregion

int main () {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if (s == u) a--;
    else if (t == u) b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
         FastScanner sc = new FastScanner();
         PrintWriter out = new PrintWriter(System.out);
        int n=sc.nextInt();
        int a[]=sc.readArray(n);
        long sum = 0, pm = 0, mp = 0;
        for(int i=0; i<n; ++i){
            sum += a[i];
            if(i%2 == 0 && sum <= 0){
                pm += 1-sum;
                sum = 1;
            }
            if(i%2 != 0 && sum >= 0){
                pm += 1+sum;
                sum = -1;
            }
        }
        sum = 0;
        for(int i=0; i<n; ++i){
            sum += a[i];
            if(i%2 == 0 && sum >= 0){
                mp += 1+sum; sum = -1;
            }
            if(i%2 != 0 && sum <= 0){
                mp += 1-sum; sum = 1;
            }
        }
        System.out.println(Math.min(pm,mp));
        out.flush();
    }

    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long[] readArrayLong(long n) {
            long[] a=new long[(int)n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 44672
#!/usr/bin/env ruby

if __FILE__ == $0 then
	man = Array.new(4).map { Array.new(3).map { Array.new(10, 0) } }
	n = gets.chomp.to_i

	1.upto(n) do
		b,f,r,v = gets.split.map { |x| x.to_i }
		man[b-1][f-1][r-1] += v
	end

	puts " "+man.map { |x| x.map { |y| y.join(" ") }.join("\n ") }.join("\n"+"#"*20+"\n ")
end



Measured memory_bytes: 6900
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int dist[N + 5];

vector<int> lst[N + 5];
queue<int> q;

int diameter(int n) {
	memset(dist, -1, sizeof dist);
	int pos;
	q.push(1);
	dist[1] = 0;
	while(!q.empty()) {
		pos = q.front();
		q.pop();
		for(auto x: lst[pos]) {
			if(dist[x] == 0) continue;
			dist[x] = 0;
			q.push(x);
		}
	}
	q.push(pos);
	dist[pos] = 1;
	while(!q.empty()) {
		pos = q.front();
		q.pop();
		for(auto x: lst[pos]) {
			if(dist[x] != 0) continue;
			dist[x] = dist[pos] + 1;
			q.push(x);
		}
	}
	return dist[pos] % 3;
}

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i < n;i++) {
		int u, v;
		cin>>u>>v;
		lst[u].PB(v);
		lst[v].PB(u);
	}
	int l = diameter(n);
	if(l == 2) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 13556
n = int(input())
Arr = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    print(f'node {i}: key = {Arr[i]}, ', end = '')
    if i > 1:
        print(f'parent key = {Arr[i//2]}, ', end = '')
    if i*2 <= n:
        print(F'left key = {Arr[i*2]}, ', end = '')
    if i*2 + 1 <= n:
        print(f'right key = {Arr[i*2 + 1]}, ', end = '')
    print()


Measured memory_bytes: 5692
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        s = [input().rstrip() for _ in range(H)]

        for i in range(H):
            s[i] = '.' + s[i] + '.'
        frame = ['.' * (W + 2)]
        s = frame + s + frame

        for h in range(1, H + 1):
            for w in range(1, W + 1):
                if s[h][w] == '#':
                    cnt = 0
                    for lr, ud in (0, -1), (0, 1), (-1, 0), (1, 0):
                        if s[h + lr][w + ud] == '#':
                            cnt += 1
                    if cnt == 0:
                        print('No')
                        exit()
        print('Yes')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the set
//order_of_key(k) - Number of elements striclty samller than k
string findSum(string str1, string str2) 
{ 
    // Before proceeding further, make sure length 
    // of str2 is larger. 
    if (str1.length() > str2.length()) 
        swap(str1, str2); 
  
    // Take an empty string for storing result 
    string str = ""; 
  
    // Calculate length of both string 
    int n1 = str1.length(), n2 = str2.length(); 
  
    // Reverse both of strings 
    reverse(str1.begin(), str1.end()); 
    reverse(str2.begin(), str2.end()); 
  
    int carry = 0; 
    for (int i=0; i<n1; i++) 
    { 
        // Do school mathematics, compute sum of 
        // current digits and carry 
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry); 
        str.push_back(sum%10 + '0'); 
  
        // Calculate carry for next step 
        carry = sum/10; 
    } 
  
    // Add remaining digits of larger number 
    for (int i=n1; i<n2; i++) 
    { 
        int sum = ((str2[i]-'0')+carry); 
        str.push_back(sum%10 + '0'); 
        carry = sum/10; 
    } 
  
    // Add remaining carry 
    if (carry) 
        str.push_back(carry+'0'); 
  
    // reverse resultant string 
    reverse(str.begin(), str.end()); 
  
    return str; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,a;
    cin>>x>>a;
    if(x<a)
    	cout<<"0"<<endl;
    else
    	cout<<"10"<<endl;
}

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

#define    ll     long long int

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

int h, w;

int isValid(int x, int y)
{
    if (x >= 0 && x < h && y >= 0 && y < w) {
        return 1;
    }
    return 0;
}

int main( )
{
    cin >> h >> w;
    string grid[55];
    int i, j, k, c = 0;
    for (i = 0; i < h; i++) {
        cin >> grid[i];
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (grid[i][j] == '.') {
                c = 0;
                for (k = 0; k < 8; k++) {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if (isValid(x, y) && grid[x][y] == '#')
                        c++;
                }
                grid[i][j] = char(c + '0');
            }
        }
    }
    for (i = 0; i < h; i++) {
        cout << grid[i] << '\n';
    }
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector< vector<int> > a(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  vector<long long> dp(1 << n);
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if ((i & (1 << j)) && (i & (1 << k))) {
          dp[i] += a[j][k];
        }
      }
    }
    int sub = i;
    while (sub > 0) {
      sub = (sub - 1) & i;
      dp[i] = max(dp[i], dp[sub] + dp[i ^ sub]);
    }
  }
  cout << dp[(1 << n) - 1] << '\n';
  return 0;
}

Measured memory_bytes: 768