akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        s: [Chars; n],
    }
    let mut graph = vec![vec![1<<25; n]; n];
    let mut uft = UFT::new(2*n);
    for y in 0..n {
        for x in 0..n {
            if x == y {
                graph[x][x] = 0;
                continue;
            }
            let d = s[y][x].to_digit(10).unwrap();
            if d == 1 {
                graph[y][x] = d;
                uft.merge(y, x+n);
                uft.merge(x, y+n);
            }
        }
    }

    if uft.root(0) == uft.root(n) {
        println!("-1");
        return;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }

    let mut ans = 0;
    for edge in &graph {
        ans = max(ans, edge.iter().cloned().max().unwrap());
    }
    println!("{}", ans+1);
}

#[allow(dead_code)]
/// Union Find Tree
pub struct UFT {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}
impl UFT {
    #[allow(dead_code)]
    pub fn new(n: usize) -> Self {
        UFT {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }
    #[allow(dead_code)]
    pub fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.root(p);
            self.par[x] = pp;
            pp
        }
    }
    #[allow(dead_code)]
    pub fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
}


Measured memory_bytes: 2552
#include "iostream"
#include "bits/stdc++.h"
#define int long long
using namespace std;
inline int min(int a,int b)
{
    return a<=b?a:b;
};
int32_t main()
{
    int n;
    cin >> n;
    vector<pair<int ,int>>v;
    for(int i = 1 ; i<=sqrt(n);i++){
        if(n%i==0){
            v.push_back({i,n/i});
        }
    }
    int ans = 1000000000001LL;
    for(int i = 0 ; i < v.size() ; i++ ){
        ans = min(ans,v[i].first+v[i].second);
    }
    cout<<ans-2;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n,k;
    cin>>n>>k;
    int a1[n+1] = {0};
    int ans = 0;
    while(k--)
    {
       int d;
       cin>>d;
       int a2;
       for(int i=0;i<d;i++)
       {
           cin>>a2;
           a1[a2] = 1;
       }
    }
    for(int i=1;i<=n;i++)
    {
        if(a1[i]==0)
            ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3672
($N,$M,$a,@A)=glob`dd`;($b=$_)+=$b<$a&&$M,$s+=$k=$b-$a,$@[$b-1]-=$k,$@[$a]++,$a=$_,$@[$b]+=$k-1for@A;@@=map$c+=$_,$c=0,@@for a,b;$%+=$-=$@[$_]+$@[$_+$M]-$%for 1..$M;print$s-$%

Measured memory_bytes: 54976
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

string s;
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> s;
	int n = s.length();
	s = "*" + s;
	for(int i=1; i<=n; i++){
		if ((i&1 && s[i] == 'L') || (i%2==0 && s[i] == 'R')) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void){
    long unsigned int n;
    cin >> n;
    string c;
    cin >> c;

    string r;

    if (c.size() > n) {
        rep(i,(int)n) {
            r += c[i];
        }
        r += "...";
    } else {
        r = c;
    }

    cout << r;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <functional>
using ll = long long;
using namespace std;

template <class T> class SegTree {
    int N;
    vector<T> data;
    T ide; // Identity element (Initial value)
    function<T(T, T)> operation; // Function for range query
    function<T(T, T)> updater; // Function for point update

    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return ide;
        if (a <= l && r <= b) {
            return data[k];
        } else {
            T left = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            T right = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return operation(left, right);
        }
    }

public:
    // int n:                       Size of array
    // T ide:                       Identity element
    // function<T(T, T)> operation: Function to merge elements
    // function<T(T, T)> updater:    (old data[i], some value x) -> new data[i]
    SegTree(size_t n, T ide, function<T(T, T)> operation,
            function<T(T, T)> updater) : ide(ide), operation(operation), updater(updater) {
        N = 1;
        while (N < n) N *= 2;
        data.resize(2 * N - 1, ide);
    }

    void update(int i, T x) {
        i += N - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, N);
    }

    T operator[](int i) {
        return data[i + N - 1];
    }
};

// AOJ Range Minimum Query
int main() {
    int N, Q;
    cin >> N >> Q;

    ll ide = (1LL << 31) - 1;
    auto operation = [](ll left, ll right) -> ll { return min(left, right); };
    auto updater = [](ll old, ll x) -> ll { return x; };
    auto seg = new SegTree<ll>(N, ide, operation, updater);

    for (int q = 0; q < Q; q++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (!c) seg->update(x, y);
        else cout << seg->query(x, y+1) << endl;
    }
}


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

int main(){
    int n; cin >> n;
    int m = n, tot = 0;
    while(m){
        tot += m%10;
        m /= 10;
    }
    if(n%tot==0) cout << "Yes";
    else cout << "No";
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Points2> a = new ArrayList<Points2>();
		for (int i = 0; i < n; i++) {
			Points2 p = new Points2(sc.nextInt(), sc.nextInt());
			a.add(p);
		}
		Collections.sort(a, Comparator.reverseOrder());

		ArrayList<Points> b = new ArrayList<Points>();
		for (int i = 0; i < n; i++) {
			Points p = new Points(sc.nextInt(), sc.nextInt());
			b.add(p);
		}
		Collections.sort(b);

		int cnt = 0;
		int m = n;
		for(int i = 0; i < n; i++) {
			Points p1 = b.get(i);
			for(int j = 0; j < m; j++) {
				Points2 p2 = a.get(j);
				if(p1.x - p2.x > 0 && p1.y - p2.y > 0) {
					cnt++;
					a.remove(j);
					m--;
					break;
				}
			}
		}

		System.out.println(cnt);
	}
}

class Points implements Comparable<Points>{
	public int x;
	public int y;

	public Points(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Points arg0) {
		if(this.x != arg0.x) {
			return this.x - arg0.x;
		} else if (this.x == arg0.x && this.y != arg0.y) {
			return this.y - arg0.y;
		} else {
			return 0;
		}
	}
}

class Points2 implements Comparable<Points2>{
	public int x;
	public int y;

	public Points2(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Points2 arg0) {
		if(this.y != arg0.y) {
			return this.y - arg0.y;
		} else if (this.y == arg0.y && this.x != arg0.x) {
			return this.x - arg0.x;
		} else {
			return 0;
		}
	}
}

Measured memory_bytes: 23764
import java.math.*

fun main(args: Array<String>) {
    val INF = 1000000000

    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    
    // (価格, 開けられる宝箱のbit)
    val keys = Array(M) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        var bit = 0
        for (c in readInputLine().split(" ").map { it.toInt() - 1 }) {
            bit = bit or (1 shl c)
        }
        Pair(a, bit)
    }
    
    val boxBits = bits(N)
    
    val dp = IntArray(boxBits + 1) { INF }
    dp[0] = 0
    
    for (k in keys) {
        for (i in 0..boxBits) {
            dp[i or k.second] = Math.min(dp[i or k.second], dp[i] + k.first)
        }
    }

    println(if (dp[boxBits] != INF) dp[boxBits] else -1)
}

fun readInputLine(): String {
    return readLine()!!
}

fun bits(x: Int): Int {
    var ret = 1
    
    for (i in 1..x) {
        ret *= 2
    }
    
    return ret - 1
}


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

int main() {
    int n;
    cin >> n;
    bool ans = false;
    for (int i = 0; i <= n / 7; i++) {
        for (int j = 0; j <= n / 4; j++) {
            if (i * 7 + j * 4 == n)
                ans = true;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}else {
				map.put(s, 1);
			}
		}
		List<Entry<String, Integer>> list = new ArrayList<Entry<String, Integer>>(map.entrySet());
		
		Collections.sort(list, new Comparator<Entry<String, Integer>>(){
			public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2) {
				return obj2.getValue().compareTo(obj1.getValue());
			}
		});
		
		int num = 0;
		int an = 0;
		ArrayList<String> l = new ArrayList<>();
		for(Entry<String, Integer> entry : list) {
			if(!entry.getValue().equals(num) && num != 0) {
				break;
			}else {
				l.add(entry.getKey());
				num = entry.getValue();
				an++;
			}
		}
		Collections.sort(l);
		for(String s : l) {
			System.out.println(s);
		}
	}
	
	static 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: 75888
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
vector<int> g[202020];
int a, b;
int d[202020];

void dfs(int cur, int pre){
    if(pre != -1)d[cur] = d[pre] + 1;
    REP(i, (int)g[cur].size()){
        if(g[cur][i] != pre){
            dfs(g[cur][i], cur);
        }
    }
}

bool isf(int num){
    num--;
    return num %= 3;
}

int main(){
    cin >> n;
    REP(i, n - 1){
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(0, -1);
    int maxl = -1, maxnum = -1;
    REP(i, n){
        if(maxl < d[i]){
            maxl = d[i];
            maxnum = i;
        }
        d[i] = 0;
    }
    dfs(maxnum, -1);
    maxl = -1, maxnum = -1;
    REP(i, n){
        if(maxl < d[i]){
            maxl = d[i];
        }
    }
    cout << (isf(maxl) ? "First" : "Second") << endl;
}

Measured memory_bytes: 21376
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

#if 1

void Prime_factorize(vector<int>& v,int n){
  if(n<=1) return;
  int l=int(sqrt(n));
  for(int i=2;i<l+1;i++){
    if(n%i==0){
      Prime_factorize(v,i);Prime_factorize(v,int(n/i));return;
    }
  }
  v.push_back(n);return;
}

#endif


int main(){
  int n;cin >> n;
  vector<int> v;
  Prime_factorize(v,n);
  sort(v.begin(),v.end());
  cout << n << ":";
  for(auto i=v.begin();i<v.end();i++){
    cout << " " << *i;
  }
  cout << endl;
}



Measured memory_bytes: 3152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTAKOYAKIFESTIVAL2019 solver = new BTAKOYAKIFESTIVAL2019();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTAKOYAKIFESTIVAL2019 {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int a = 0;
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++)
                    a += arr[i] * arr[j];
            pw.println(a);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



Measured memory_bytes: 22228
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
string s;
int dp[N][15];
int go(int pos,int rem)
{
    if(pos==s.size())
    {
        return rem==5;
    }
    if(dp[pos][rem]!=-1)
    {
        return dp[pos][rem];
    }
    int ans=0;
    if(s[pos]=='?')
    {
        for(int i=0;i<=9;i++)
        {
            ans+=go(pos+1,(rem*10+i)%13);
            ans%=MOD;
        }
    }
    else
    {
        ans+=go(pos+1,(rem*10+s[pos]-'0')%13);
        ans%=MOD;
    }
    return dp[pos][rem]=ans;
}
int32_t main()
{
    
    cin>>s;

    memset(dp,-1,sizeof(dp));
    cout<<go(0,0)<<endl;
}


Measured memory_bytes: 18432
#include<cstdio>
long long a, v, t, w, b;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
	if(a == b || (a < b && a + v * t >= b + w * t) || (a > b && a - v * t <= b - w * t))
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 3228
c = 0

while c <= 3:
    t, n = map(int,input().split())
    c = c + 1

    if t == 1:
        n = n*6000
    elif t == 2:
        n = n*4000
    elif t == 3:
        n = n*3000
    elif t == 4:
        n = n*2000

    print(n)


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



int main() {
    int a, b, c, d, e;
    while(scanf("%d,%d,%d,%d,%d", &a, &b, &c, &d, &e) != EOF){
        vector<int> v{a, b, c, d, e};
        [&](){
            vector<int> cnt(14);
            for (int i = 0; i < 5; ++i) {
                cnt[v[i]]++;
            }
            int two = 0, three = 0;
            for (int i = 0; i < 14; ++i) {
                if(cnt[i] == 4) {
                    puts("four card");
                    return;
                }else if(cnt[i] == 3) three++;
                else if(cnt[i] == 2) two++;
            }
            if(three && two){
                puts("full house");
                return;
            }
            sort(v.begin(),v.end());
            if(v == vector<int>{1, 10, 11, 12, 13}){
                puts("straight");
                return;
            }
            int ok = 1;
            for (int i = 0; i < 4; ++i) {
                if(v[i]+1 != v[i+1]) ok = 0;
            }
            if(ok){
                puts("straight");
                return;
            }
            if(three) puts("three card");
            else if(two == 2) puts("two pair");
            else if(two) puts("one pair");
            else puts("null");
        }();
    }
    return 0;
}


Measured memory_bytes: 3120
#include "stdio.h"
#include "string.h"

int main(void)
{
	int i,j;
	int n,a;
	char s[100] = {0};
	char t[2] = {0};

	scanf("%s", s);
	n = strlen(s);

	for(i = 0; i < n; i++)
	{
		if (s[i] == 'C')
		{
			t[0] = 'C';
			a = i;
			break;
		}
	}
	
	if (t[0] == 'C')
	{

		for(j = a; j < n; j++)
		{
			if (s[j] == 'F')
			{
				t[1] = 'F';
				break;
			}
		}
	}

	
	if (t[0] == 'C' && t[1] == 'F')
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int mod=1000000007;
int main(){
    int n,m;cin>>n>>m;
    vector<int> a(n+1,-1);
    rep(i,m){
        int x;cin>>x;
        a[x]=0;
    }
    a[0]=1;
    if(a[1]==-1)a[1]=1;
    for(int i=2;i<=n;i++){
        if(a[i]==0)continue;
        a[i]=a[i-1]+a[i-2];
        a[i]%=mod;
    }
    cout<<a[n]<<endl;
}

Measured memory_bytes: 3764
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long a = sc.nextLong();
	long b = sc.nextLong();
	long c = sc.nextLong();
	long d = sc.nextLong();
	long cd = lcm(c,d);
	System.out.print(b-a+1-(b/c - (a-1)/c + b/d - (a-1)/d - b/cd + (a-1)/cd));
    }
    static long gcd(long m, long n) {
	if (m < n) {
	    long tmp = m;
	    m = n;
	    n = tmp;
	}
	long rem = 0;
	while ((rem = m%n) != 0) {
	    m = n;
	    n = rem;
	}
	return n;
    }
    static long lcm(long m, long n) {
	return m * n / gcd(m, n);
    }
}


Measured memory_bytes: 35632
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

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

    string s;
    cin >> s;

    int black = 0;
    REP(i, s.size()) if (s[i] == 'B') black++;
    int dist = s.size() - 1;
    vector<int> v(s.size());
    REP(i, s.size()) {
        if (s[i] == 'B') {
            v[i] = dist - i - black + 1;
            black--;
        }
    }

    ll ans = 0;
    REP(i, v.size()) { ans += v[i]; }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 1428
#include<iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{
  int a,b;

  std::cin >> a >> b;

  if(a<=8&&b<=8)
    std::cout << "Yay!" << '\n';
  else
    std::cout << ":(" << '\n';

	return 0;
}


Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 1e9
long double PI =3.14159265358979323846;
 
const ll M=1e12;
const ll inf=1e18;
const ll ms=10000000;
fast;
ll ans,n;
void solve()
{
    cin>>n;ll a[n+1],b[n+1];
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
    {
        ll temp=min(a[i-1],b[i]);
        ans+=temp;b[i]-=temp;temp=min(a[i],b[i]);
        ans+=temp;b[i]-temp;a[i]-=temp;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  for ( ; ; N ++) {
    int a = N / 100, b = N / 10 % 10, c = N % 10;

    if (a == b && b == c) {
      std::cout << N << std::endl;

      break;
    }
  }
  

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
const int N=1e4+5,M=N<<1;

int n,d[N],c[N],ans[N];
long long sum;

struct qxx{int nex,t;};
qxx e[M];
int h[N],le=1;
void add_path(int f,int t){e[++le]=(qxx){h[f],t},h[f]=le;}

queue<int> q;

int main(){
    scanf("%d",&n);
    FOR(i,1,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        add_path(a,b),add_path(b,a);
        d[a]++,d[b]++;
    }
    FOR(i,1,n)scanf("%d",&c[i]);
    sort(c+1,c+n+1);
    int tot=0;
    FOR(i,1,n)if(d[i]==1)q.push(i);
    while(!q.empty()){
        int u=q.front();q.pop();
        ans[u]=c[++tot];
        if(q.empty())break;
        int cnt=0;
        for(int i=h[u];i;i=e[i].nex){
            const int v=e[i].t;
            if(d[v]==0)continue;
            --d[u],--d[v];
            if(d[v]==1)q.push(v);
            ++cnt;
        }
        assert(cnt==1);
    }
    FOR(i,1,n-1)sum+=c[i];
    printf("%lld\n",sum);
    FOR(i,1,n)printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, p, prev = 0, k = 1;
    cin >> n >> p;
    string s;
    vector<int> a(n);
    cin >> s;
    for (int i = n - 1; i >= 0; i--)
    {
        a[i] = (k * (int)(s[i] - '0') + prev) % p;
        prev = a[i];
        k = (k * 10) % p;
    }
    LL ans = 0;
    vector<int> M(p);
    if (p != 2 && p != 5)
    {
        for (int i = 0; i < n; i++)
        {
            if (i)
            {
                ans += M[a[i]];
            }
            if (a[i] == 0)
            {
                ans++;
            }
            M[a[i]]++;
        }
    }
    else if (p == 2)
    {
        fr(n)
        {
            if ((int)(s[i] - '0') % 2 == 0)
            {
                ans += i + 1;
            }
        }
    }
    else
    {
        fr(n)
        {
            if ((int)(s[i] - '0') % 5 == 0)
            {
                ans += i + 1;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1488
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

x = reduce(lcm, a) - 1
ans = 0
for i in a:
    ans += x % i
print(ans)

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

c = []
for i in range(h):
   tmp = [x for x in input()]
   c.append(tmp)

for i in range(h):
   tmp = [print(x, end='') for x in c[i]]
   print()
   tmp = [print(x, end='') for x in c[i]]
   print()


Measured memory_bytes: 4472
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    double n,k,s=0,c=0.5;cin>>n>>k;
    for(int i=1;i<=n;i++){
    	int a=1,b=i;
    	while(b<k) a++,b*=2;
    	s=s+pow(c,a-1);
	}
	double dd=s/n;
	cout<<fixed<<setprecision(12)<<dd;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_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(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a, res = 0, mn = INF, cnt = 0;
    cin>>n;
    rep(i, n) {
        cin>>a;
        if(a < 0) cnt++;
        a = abs(a), chmin(mn, a), res +=a;
    }
    if(cnt % 2) cout<<res - 2 * mn<<endl;
    else cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#include<string>
using namespace std;
ll n,a[100008],dp[100008];
ll f(ll i)
{
	if(i>n-1)
		return 0;
	if(dp[i]==-1)
	{
		dp[i]=0;
		ll temp1=0,temp2=0;
		if(i+1<=n-1)
		temp1=abs(a[i]-a[i+1]);
		if(i+2<=n-1)
		temp2=abs(a[i]-a[i+2]);
		if(i+2<=n-1&&i+1<=n-1)
		dp[i]= min(temp1+f(i+1),temp2+f(i+2));
		else
		dp[i]= max(temp1+f(i+1),temp2+f(i+2));
	}
	return dp[i];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
		cin>>a[i];
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> leg(N);
  for (int i=0; i < N ; i++){
    cin >> leg.at(i);
  }
  sort(leg.begin(), leg.end(), greater<int>());
  int ans =0;
  for (int i=0; i < K ; i++){
    ans += leg.at(i);
  }
  
  cout << ans << endl;
} 


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
int main() {
  long long x;
  cin >> x;
  bitset<32> bit(x);
  cout << bit << endl;
  cout << ~bit << endl;
  cout << (bit<<1) << endl;
  cout << (bit>>1) << endl;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
int L[55];
int P[55];
int calc(int n,int x){
    if(x<=0)return 0;
    if(n==0)return 1;
 
    int res=0;
    if(L[n-1]+1<=x)res+=P[n-1];
    else res+=calc(n-1,x-1);
 
    if(1+L[n-1]+1<=x)res++;
    if(1+L[n-1]+1+L[n-1]<=x)res+=P[n-1];
    else res+=calc(n-1,x-1-L[n-1]-1);
    return res;
}
 
signed main(){
    L[0]=1;
    P[0]=1;
    for(int i=1;i<55;i++){
        L[i]=L[i-1]*2+3;
        P[i]=P[i-1]*2+1;
    }
    int N,X;cin>>N>>X;
    cout<<calc(N,X)<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums: HashMap<_, i32> = aa.iter()
        .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 27576
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = new LinkedList<char>(ReadLine());
        var Q = int.Parse(ReadLine());

        var isFlipped = false;

        for (int i = 0; i < Q; i++)
        {
            var query = ReadLine().Split(' ').ToArray();

            var T = int.Parse(query[0]);
            switch (T)
            {
                case 1:
                    isFlipped = !isFlipped;

                    break;

                case 2:
                    var F = int.Parse(query[1]);
                    var C = query[2][0];
                    switch (F)
                    {
                        case 1:
                            if (!isFlipped)
                                S.AddFirst(C);
                            else
                                S.AddLast(C);

                            break;

                        case 2:
                            if (!isFlipped)
                                S.AddLast(C);
                            else
                                S.AddFirst(C);
                            break;

                        default:
                            break;
                    }
                    break;

                default:
                    break;
            }
        }

        var ans = new string((isFlipped ? S.Reverse() : S).ToArray());

        WriteLine(ans);
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

ll n;

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

    cin >> n;
	if (n == 0) {
		cout << "0" << endl;
		return 0;
	}
    string ans;
	int m = 1;
	while(n) {
		ans = to_string(abs(n) % 2) + ans;
		n -= (abs(n) % 2) * m;
		m *= -1;
		n /= 2;
    }
	cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long diff=0;
    long long last;
    long long inp;
    cin >> last;
    string ans="Yes";
    if(N>1){
        for(int i=1; i<N; i++){
            cin >> inp;
            if(inp<=last){
                diff+=(last-inp);
            }else{
                diff=0;
            }
            last=inp;
            if(diff>=2){
                ans="No";
                break;
            }
        }
    }
    cout << ans;
    return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n;cin>>n;
    int a[n+1];
    for(ll i=1;i<=n;i++)cin>>a[i];
    ll c;
    ll ans[n+1];
    ll count;
    vector<ll> an;
    for(ll j=n;j>=1;j--){
        count=0;
        for(c=j*2;c<=n;c=c+j){
            count+=ans[c];
        }
        ans[j]=(count+a[j])%2;
        if(ans[j]==1){
            an.push_back(j);
        }
    }
    reverse(an.begin(),an.end());
    cout<<an.size()<<endl;
    if(an.size()>0){
        cout<<an[0];
        for(ll i=1;i<an.size();i++){
            cout<<' '<<an[i];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 4340
import math
def isPrime(x):
    if x <= 1:
        return False
    if x == 2:
        return True
    for i in range(2, int(math.ceil(x**0.5))+1):
        if x % i == 0:
            return False
    return True

n = input()
l = [input() for i in range(n)]
count = 0
for i in l:
    if isPrime(i):
        count += 1
print count

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

int main() {
  int N, S=0;
  cin >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V.at(i);
  }
  for (int i=1; i<N; i++) {
    for (int j=0; j<i; j++) {
      S += V.at(i) * V.at(j);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            if (w + h == 0) {
                break;
            }
            for (int i=0; i<w; ++i) {
                for (int j=0; j<h; ++j) {
                    System.out.print(((i+j)%2==1 ? "." : "#"));
                }
                System.out.println("");
            }
            System.out.println("");
        }
        sc.close();
    }
}



Measured memory_bytes: 34928
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void send_query1(int l, int r) {
    // fprintf(stderr, "# query 1\n");
    cout << "?";
    for(int i=l; i<r; i++) {
        cout << " " << i;
    }
    cout << endl;
}

void send_query2(const vector<int> &vec, int k) {
    // fprintf(stderr, "# query 2\n");
    cout << "?";
    for(auto e : vec) cout << " " << e;
    cout << " " << k << endl;
}

void send_query3(const vector<int> &red,
                 const vector<int> &blue, int k) {
    // fprintf(stderr, "# query 3\n");
    cout << "?";
    for(auto e : red ) cout << " " << e;
    for(auto e : blue) cout << " " << e;
    cout << " " << k << endl;
}

char recieve_color() {
    string s; cin >> s;
    if(s == "-1") exit(1);
    return (s == "Red" ? 'R' : 'B');
}

void answer_query(string ans) {
    cout << "! " << ans << endl;
}

int main() {
    int N; cin >> N;
    string ans(2*N+1, '?');
    
    const char NIL = '?';

    send_query1(1, 1+N);
    char L = recieve_color();
    send_query1(N+1, N+1+N);
    char R = recieve_color();
    if(L == R) R = 'B' ^ 'R' ^ L;

    int ub = N+1, lb = 1;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        send_query1(mid, mid+N);
        char P = recieve_color();
        if(P == L) lb = mid;
        else ub = mid;
    }
    
    {
        int i = ub;
        // i-1 番目は pre の色
        // i+N-1 番目は cur の色
        ans[i-1] = L;
        ans[i+N-1] = R;
        
        // [i, i+N-2] に青と赤が (N-1)/2 ずつ含まれる
        vector<int> vec;
        for(int j=i; j<=i+N-2; j++) vec.emplace_back(j);
        
        for(int j=1; j<=2*N; j++) {
            if(ans[j] != NIL) continue;
            if(i <= j and j <= i+N-2) continue;
            send_query2(vec, j);
            ans[j] = recieve_color();
        }
        
        int target = (N - 1) / 2;
        vector<int> red, blue;
        for(int j=1; j<=2*N; j++) {
            if(ans[j] == 'R' and red.size() < target) red.emplace_back(j);
            if(ans[j] == 'B' and blue.size() < target) blue.emplace_back(j);
        }
        
        for(int j=1; j<=2*N; j++) {
            if(ans[j] != NIL) continue;
            send_query3(red, blue, j);
            ans[j] = recieve_color();
        }
    }
    answer_query(ans.substr(1));
    return 0;
}


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

int main(){
    int n,k,c=0,ans;
    int a[100005];
    int c_odd[100005];
    int c_even[100005];
    int tmp;
    int no_1_odd = 0;
    int no_2_odd = 0;
    int no_1_even = 0;
    int no_2_even = 0;
    int even,odd;
    
    //input
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a[i];
    }

    //最頻値計算
    for(int i=0; i<n; i+=2){
        c_odd[a[i]]+=1;
    }
    for(int i=1; i<n; i+=2){
        c_even[a[i]]+=1;
    }
    for(int i=0; i<100005; i++){
        if(no_1_odd < c_odd[i]){
            no_2_odd = no_1_odd;
            no_1_odd = c_odd[i];
            odd = i;
        }else if(no_2_odd < c_odd[i]){
            no_2_odd = c_odd[i];
        }
    }
    for(int i=0; i<100005; i++){
        if(no_1_even < c_even[i]){
            no_2_even = no_1_even;
            no_1_even = c_even[i];
            even = i;
        }else if(no_2_even < c_even[i]){
            no_2_even = c_even[i];
        }
    }

    if(even != odd){
        ans = n - (no_1_even + no_1_odd);
    }else{
        if(no_2_even > no_2_odd){
            ans = n - (no_2_even + no_1_odd);
        }else{
            ans = n - (no_1_even + no_2_odd);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
mod = 1000000007
_, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
count1, count2 = 0, 0
arr.each_with_index do |v, i|
  tmp_count1, tmp_count2 = 0, 0
  arr.each_with_index do |vv, ii|
    tmp_count1 += 1 if vv > v && ii < i
    tmp_count2 += 1 if vv > v
  end
  count1 += tmp_count1
  count2 += tmp_count2
end
ans = (count1 * k) % mod
ans = (ans + k * (k - 1) * count2 / 2) % mod
puts ans

Measured memory_bytes: 1788