akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  double mean = 0;
  for(int j=0; j<N; j++){
    mean += vec.at(j);
  }
  mean = mean / N;
  
  double num_min = 100000000;
  int ans = 0;
  
  for(int k=0; k<N; k++){
    if(abs(vec.at(k) - mean) < num_min){
      num_min = abs(vec.at(k) - mean);
      ans = k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	double A,B,H,M; cin>>A>>B>>H>>M;
	double x = M / 60;
	double y = (60 * H + M) / 720;
	double pi = 3.141592653589793238;
	cout.precision(15);
	cout<<fixed<<sqrt(A * A + B * B - 2 * A * B * cos(abs(x - y) * 2 * pi))<<endl;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  map<char, int> mp;
  rep(i, h){
    string s;
    cin >> s;
    rep(j, w) mp[s.at(j)]++;
  }
  int p4 = 0, p2 = 0, p1 = 0;
  for(auto p : mp){
    p4 += p.second/4;
    p.second %= 4;
    p2 += p.second/2;
    p.second %= 2;
    p1 += p.second;
  }
  bool ans = false;
  if(h % 2 == 1 && w % 2 == 1){
    if(p1 != 1) ans = true;
  }else{
    if(p1 != 0) ans = true;
  }
  int hw = (h/2)*(w/2);
  if(p4 < hw) ans = true;
  if(ans == false) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
	double a[100];
	int N;
	cin >> N;
	double res1 = 0, res2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		res1 += 1 / a[i];
	}
	res2 = 1 / res1;
	cout << res2 << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	
	while(1){
		int a, b;
		long ans;
		char op;
	
		scanf(" %d %c %d", &a, &op, &b);
		if(op=='?') break;
		else if(op=='+') ans=a+b;
		else if(op=='-') ans=a-b;
		else if(op=='*') ans= a*b;
		else if(op=='/') ans=a/b;
		
		printf("%ld\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//
		int TAROpoint =0;
		int HANAKOpoint =0;
		//n?????????
		int n = sc.nextInt();
		for(int i=0; i<n; i++){
			//??????????????????
			String TAROcard = sc.next();
			//??±???????????????
			String HANAKOcard = sc.next();
			//?????????????????????
			if(HANAKOcard.compareTo(TAROcard) < 0){
				//??????????????????
				TAROpoint+= 3;
			}else if(HANAKOcard.compareTo(TAROcard)==0){
				//?????????1????????????
				TAROpoint++;
				HANAKOpoint++;
			}else{
				//??±???????????????
				HANAKOpoint+=3;
			}
		}
		//??¨??? ?????????????????? ??±???????????????
		System.out.println( TAROpoint +" "+ HANAKOpoint);
		
	}
}

Measured memory_bytes: 29456
const main = (input: any): void => {
  let [N, K] = (input.split('\n')[0].split(' '))
  N = Number(N)
  K = Number(K)
  console.log(K * ((K - 1) ** (N - 1)))
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
//2018.12.29 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int kcz=1e9+7;
const int N=3e3+10;
namespace MAIN{
    int n,q;
    int a[N];
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    inline int qpow(res x,res y){
        res ret=1;
        while(y){
            if(y&1)ret=1LL*x*ret%kcz;
            x=1LL*x*x%kcz,y>>=1;
        }
        return ret;
    }
    int f[N][N],g[N][N],ans,INV,X[N],Y[N];
    inline void MAIN(){
        n=read(),q=read(),INV=qpow(2,kcz-2);
        for(res i=1;i<=n;i++){
            a[i]=read();
            for(res j=i+1;j<=n;j++)f[i][j]=1;
        }
        for(res i=1;i<=q;i++)X[i]=read(),Y[i]=read();
        for(res t=1;t<=q;t++){
            res x=X[q-t+1],y=Y[q-t+1];
            for(res i=1;i<=n;i++)g[x][i]=f[x][i],g[i][x]=f[i][x],g[y][i]=f[y][i],g[i][y]=f[i][y];
            for(res i=1;i<=n;i++){
                f[x][i]=1LL*Add(f[x][i],g[y][i])*INV%kcz,f[i][x]=1LL*Add(f[i][x],g[i][y])*INV%kcz;
                f[y][i]=1LL*Add(f[y][i],g[x][i])*INV%kcz,f[i][y]=1LL*Add(f[i][y],g[i][x])*INV%kcz;
            }
            f[x][y]=f[y][x]=1LL*Add(g[x][y],g[y][x])*INV%kcz;
        }
        for(res i=1;i<=n;i++)
            for(res j=1;j<=n;j++)if(a[i]>a[j])add(ans,f[i][j]);
        printf("%lld\n",1LL*qpow(2,q)*ans%kcz);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}


Measured memory_bytes: 70912
using System;
class Card{
    private char Mark;
    private int Num;
    public Card(char m, int n) {
        Mark = m;
        Num = n;
    }
    public Card() {
        Mark = 'a';
        Num = 0;
    }
    public char markop
    {
        get {
            return Mark;
        }
        set {
            Mark = value;
        }
    }
    public int numop
    {
        get {
            return Num;
        }
        set {
            Num = value;
        }
    }
}

class Sorting
{
    public void BubbleSort(Card[] cards, int N) {
        Card temp = new Card();
        for (int i = 0; i < N; i++) {
            for(int j = N - 1; j > i; j--) {
                if (cards[j].numop < cards[j - 1].numop) {
                    temp = cards[j];
                    cards[j] = cards[j - 1];
                    cards[j - 1] = temp;
                }
            }
        }
        print(cards, N);
    }

    public void SelectionSort(Card[] cards, int N) {
        Card temp = new Card();
        for (int i = 0; i < N; i++) {
            int minj = i;
            for (int j = i; j < N; j++) {
                if (cards[j].numop < cards[minj].numop) {
                    minj = j;
                }
            }
            temp = cards[i];
            cards[i] = cards[minj];
            cards[minj] = temp;
        }
        print(cards, N);
    }

    public void print(Card[] cards, int n) {
        for(int i = 0; i < n; i++) {
            if (i > 0) {
                Console.Write(" ");
            }
            Console.Write("{0}{1}", cards[i].markop, cards[i].numop);
        }
        Console.WriteLine();
    }

    public bool IsStable(Card[] cards1, Card[] cards2, int n) {
        for(int i = 0; i < n; i++) {
            if (cards1[i].markop != cards2[i].markop) {
                return false;
            }
        }
        return true;
    }
}

class CodeFile1
{
    public static void Main() {
        int n, i=0;
        Card[] cards1 = new Card[36];
        Card[] cards2 = new Card[36];
        Sorting sort = new Sorting();
        n=int.Parse(Console.ReadLine());
        string[] data = Console.ReadLine().Split(' ');
        foreach(string dataset in data){
            cards1[i] = new Card();
            cards2[i] = new Card();
            foreach(char mark in dataset) {
                if (char.IsNumber(mark)) {
                    cards1[i].numop = mark - '0';
                    cards2[i].numop = mark - '0';
                } else {
                    cards1[i].markop = mark;
                    cards2[i].markop = mark;
                }
            }
            i++;
        }
        sort.BubbleSort(cards1, n);
        Console.WriteLine("Stable");
        sort.SelectionSort(cards2, n);
        if(sort.IsStable(cards1, cards2, n)) {
            Console.WriteLine("Stable");
        } else {
            Console.WriteLine("Not stable");
        }
    }
}


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

int main()
{
  int n;
  int len[101];
  string s;
  int num[5]={5,7,5,7,7};

  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>s;
      len[i]=s.length();
    }

    int ans=0;
    for(int i=0;i<n;i++){
      int sum=0,c=0;
      for(int j=i;j<n;j++){
	sum+=len[j];
	if(sum==num[c]){
	  sum=0;
	  c++;
	}
	else if(num[c]<sum)break;
	if(c==5)break;
      }
      if(c==5){
	ans=i;
	break;
      }
    }
    cout<<ans+1<<endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
 
int main(){
  int n,m;
  cin>>n>>m;
  string start(n,'*');
  for(int i = 0;i<m;i++){
    int pos;
    char value;
    cin>>pos>>value;
    if(start[pos-1]!=value){
      if(start[pos-1]!='*'){
        start="-1";
        n=1;
        break;
      }
      else{
        start[pos-1]=value;
      }
    }
  }
  if(n==1){
    if(start=="*"){
      start="0";
    }
    cout<<start<<"\n";
    return 0;  
  }
  for(int i = 0;i<n;i++){  
    if(i==0&&start[i]=='0'){
      start="-1";
      break;
    } 
    else if(i==0&&start[i]=='*'){
      start[i]='1';
    }
    else if(start[i]=='*'){
      start[i]='0';
    }
  }
  cout<<start<<"\n"; 
  return 0; 
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k: u32 = read();
    let x: u32 = read();
    let ans = if k*500 >= x { "Yes" } else { "No" };
    println!("{}",ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();
		int a = 0;
		for(int i=0; i<3; i++) {
			if(S.charAt(i) == T.charAt(i)) a++;
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 21844
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

bool isConnected(int[26][] c) {
	bool[26] appear;
	foreach(i; 0..26) {
		foreach(j; 0..26) {
			if(c[i][j]) {
				appear[i] = true;
				appear[j] = true;
			}
		}
	}

	bool[26] arrived;

	int[] next;
	foreach(i; 0..26){
		foreach(j; 0..26) {
			if(c[i][j]){
				arrived[i] = true;
				arrived[j] = true;
				next ~= j;
			}
		}
		if(!next.empty())
			break;
	}

	while(!next.empty()) {
		int[] newNext;
		foreach(t; next) {
			foreach(i; 0..26) {
				if(!arrived[i] && c[t][i]){
					arrived[i] = true;
					newNext ~= i;
				}
			}
		}
		next = newNext;
	}
	return appear == arrived;
}

bool isEuler(int[26][] c) {
	foreach(i; 0..26) {
		int to, from;
		foreach(j; 0..26) {
			to += c[j][i];
			from += c[i][j];
		}
		if(to != from)
			return false;
	}
	return true;
}

void main() {
	auto n = to!int(readln().strip());
	while(n) {
		int[26][26] c;
		bool[26] appear;
		foreach(i; 0..n) {
			auto l = readln().strip();
			int s = l[0]-'a';
			int t = l[$-1]-'a';
			appear[s] = true;
			appear[t] = true;
			++c[s][t];
		}

		if(isConnected(c) && isEuler(c))
			writeln("OK");
		else
			writeln("NG");

		n = to!int(readln().strip());
	}
}

Measured memory_bytes: 2036
x,k,d = map(int,input().split())
n = abs(x)//d
if n>k:
  ans = min(abs(x-k*d),abs(x+k*d))
else:
  ans = min(abs(x+min(k,n)*d),abs(x-min(k,n)*d))
  if (k-n)%2:
    ans = min(abs(ans-d),abs(ans+d))
print(ans)

Measured memory_bytes: 9200
package main

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

func main() {
	sc := NewScanner()

	xs := make([]int, 5)
	for i := 0; i < 5; i++ {
		xs[i] = sc.ReadInt()
	}

	for i, x := range xs {
		if x == 0 {
			fmt.Println(i + 1)
			return
		}
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main(void){
    ll a, b, c, d, result;
    
    cin >> a >> b >> c >> d;
    result = a * c;

    if (result < a * d) result = a * d;
    if (result < b * c) result = b * c;
    if (result < b * d) result = b * d;
    
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    private int N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();

        long minus = 0;
        for (int i = 0; i < N - 1; i++)
        {
            int u = sc.NextInt();
            int v = sc.NextInt();
            if (u > v)
            {
                int t = u;
                u = v;
                v = t;
            }


            minus += (long) (u - 0) * (N - v + 1);
        }

        long plus = 0;
        for (int i = 1; i <= N; i++)
        {
            plus += (long) (i + 1) * i / 2;
        }

        Console.WriteLine(plus - minus);
    }

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

Measured memory_bytes: 40548
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

n,k = inm()
fac = [-1]*(n+1)
fac[0] = 1
for i in range(n):
    fac[i+1] = (fac[i]*(i+1))%R
for i in range(1,k+1):
    if 0>n-k-i+1:
        print(0)
    else:
        print((fac[n-k+1]*fac[k-1]*modinv2( \
           fac[i]*fac[n-k-i+1]*fac[k-i]*fac[i-1],R))%R)


Measured memory_bytes: 41840
let input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const S = input[0]
const T = input[1]

const s = S.split('')
const t = T.split('')

// console.log(s, t)

result = true

for (i = 0; i < S.length; i++) {
    if (s[i] !== t[i]) result = false
}

if (s.length !== t.length - 1) result = false

console.log(result ? 'Yes' : 'No')


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

int main() {
  //int r, g, b;
  int count = 0;
  vector<char> num(3);
  cin >> num[0] >> num[1] >> num[2];
  
  if (num[0] == '1') {
    count++;
  }
  if (num[1] == '1') {
    count++;
  }
  if (num[2] == '1') {
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second



int main() {
	ll n,y;
	cin >> n;
	ll res = 0;
	for(int i = 1; i <= n; i++) {
		y = n/i;
		res += i*y*(y+1)/2;	
	}

	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int N, K,ans;
	int num = 1;
	cin >> N >> K;
	for (int i = 1; i < N; i++) {
		num *= K - 1;
	}
	ans = K*num;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  for(int i = k; i < n; i++){
    if(a[i-k] < a[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char a[100000];
    while(cin >> a){
       for(int i = 0; i < strlen(a); i+=2){
        cout << a[i];
       }
       cout << endl;
    }
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static long C;
        static long D;
        static long lcm;

        static void Main(string[] args)
        {
            //[summary]A - Security
            var S = Console.ReadLine();

            if (IsGood(S))
            {
                Console.WriteLine("Good");
            }
            else
            {
                Console.WriteLine("Bad");
            }
        }

        static bool IsGood(string S)
        {
            for(int i = 0; i < 3; i++)
            {
                if (S[i] == S[i + 1])
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 11092
//#include<stdio.h>
//#include<stdlib.h>
#include<bits/stdc++.h>
//#define Min(a,b,c) min((a),min((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define MEM(x) memset(x,0,sizeof(x))
#define N 200005
#define pi 3.14159265359
using namespace std;
typedef long long LL;
struct town{
	int x,y,i;
};
bool cmp(const town &a,const town &b){
	return a.x>b.x;
}
bool cmp1(const town &a,const town &b){
	return a.y>b.y;
}
struct road{
	int x,y,len;
};
bool operator<(const road &a,const road &b){
	return a.len<b.len; 
} 
int f[100005];
int Find(int a){
	if(f[a]==a)
	return a;
	return f[a]=Find(f[a]);
}
	road r[200005];
		town t[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		t[i].x=a;
		t[i].y=b;
		t[i].i=i;//=mp(a,b);
	}
	sort(t,t+n,cmp);
	int index=0;
	for(int i=1;i<n;i++){
		r[index].x=t[i].i;
		r[index].y=t[i-1].i;
		r[index].len=t[i-1].x-t[i].x;
		index++;
	}
	sort(t,t+n,cmp1);
	for(int i=1;i<n;i++){
		r[index].x=t[i].i;
		r[index].y=t[i-1].i;
		r[index].len=t[i-1].y-t[i].y;
		index++;
	}
	sort(r,r+index);
	for(int i=0;i<n;i++)
	f[i]=i;
	LL ans=0;
	for(int i=0;i<index;i++){
		int a=r[i].x;
		int b=r[i].y;
		int fa=Find(a);
		int fb=Find(b);
		if(fa!=fb){
		//	printf("%d %d %d\n",a,b,r[i].len);
			f[fa]=fb;
			ans+=r[i].len;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int lim=160*80+1;
bool dp[81][81][lim];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    //できるだけ差を小さくしながらDPするのは最適じゃない
    //一番右下のマスが1,100000とかだったら死ぬから
    //マスで両者の差をとっておいて，正か負かを選べる
    //ルートの総和の最小化

    int h,w;cin>>h>>w;
    int a[h][w],b[h][w],x[h][w];
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin>>b[i][j];
            x[i][j]=abs(a[i][j]-b[i][j]);
        }
    }

    rep(i,h){
        rep(j,w){
            if(i==0&&j==0){
                dp[i][j][x[i][j]]=true;
            }
            if(i!=0){
                rep(k,lim)if(dp[i-1][j][k]){
                    if(k+x[i][j]<lim) dp[i][j][k+x[i][j]]=true;
                    dp[i][j][abs(x[i][j]-k)]=true;
                }
            }
            if(j!=0){
                rep(k,lim)if(dp[i][j-1][k]){
                    if(k+x[i][j]<lim) dp[i][j][k+x[i][j]]=true;
                    dp[i][j][abs(x[i][j]-k)]=true;
                }
            }
        }
    }
    rep(i,lim){
        if(dp[h-1][w-1][i]){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 81408
program three_variables_game
  implicit none
  integer :: n, r(4) = 0, x(100001) = 0, i, j, p(2) = 0
  character(1) :: c(4) = (/ "A", "B", "X", "C" /)
  character(2) :: s
  read(*,*) n, r(1), r(2), r(4)
  if (sum(r) == 0) then
    write(*,'(a)') "No"
    stop
  end if
  do i = 1, n
    read(*,*) s
    x(i) = hash(s)
  end do
  if (sum(r) == 1) then
    j = maxloc(r,1)
    call simulate(.false.)
    r = 0
    r(j) = 1
    call simulate(.true.)
    stop
  end if
  call get_index(x(1),p)
  if (r(p(1)) == 0 .and. r(p(2)) == 0) then
    write(*,'(a)') "No"
    stop
  else
    write(*,'(a)') "Yes"
  end if
  do i = 1, n
    call get_index(x(i),p)
    if (r(p(1)) == 0) then
      r(p(1)) = r(p(1))+1
      r(p(2)) = r(p(2))-1
      write(*,'(a)') c(p(1))
    else if (r(p(2)) == 0) then
      r(p(1)) = r(p(1))-1
      r(p(2)) = r(p(2))+1
      write(*,'(a)') c(p(2))
    else if (sum(r) == 2 .and. r(p(1))*r(p(2)) == 1 .and. i < n .and. x(i) /= x(i+1)) then
      j = 1
      if (p(2) == and(x(i),x(i+1))) j = 2
      r(p(j)) = r(p(j))+1
      r(p(3-j)) = r(p(3-j))-1
      write(*,'(a)') c(p(j))
    else if (r(p(1)) > r(p(2))) then
      r(p(1)) = r(p(1))-1
      r(p(2)) = r(p(2))+1
      write(*,'(a)') c(p(2))
    else
      r(p(1)) = r(p(1))+1
      r(p(2)) = r(p(2))-1
      write(*,'(a)') c(p(1))
    end if
  end do
contains
  integer function hash(s)
    character(2), intent(in) :: s
    select case (s)
      case ("AB")
        hash = 3
      case ("AC")
        hash = 5
      case ("BC")
        hash = 6
    end select
  end
  subroutine get_index(x,p)
    integer, intent(in) :: x
    integer, intent(out) :: p(2)
    integer :: i, k
    i = 0
    do k = 0, 2
      if (.not.btest(x,k)) cycle
      i = i+1
      p(i) = lshift(1,k)
    end do
  end
  subroutine simulate(out)
    logical, intent(in) :: out
    if (out) write(*,'(a)') "Yes"
    do i = 1, n
      call get_index(x(i),p)
      if (r(p(1)) /= 0) then
        r(p(1)) = r(p(1))-1
        r(p(2)) = r(p(2))+1
        if (out) write(*,'(a)') c(p(2))
      else if (r(p(2)) /= 0) then
        r(p(1)) = r(p(1))+1
        r(p(2)) = r(p(2))-1
        if (out) write(*,'(a)') c(p(1))
      else
        write(*,'(a)') "No"
        stop
      end if
    end do
  end
end program three_variables_game

Measured memory_bytes: 3292
import java.util.Scanner;
	
	import java.util.Arrays;
	public class Main {
		static Scanner scn = new Scanner(System.in);
		public static void main(String[] args) {
			// TODO Auto-generated method stub
			int n=scn.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=scn.nextInt();
		}
		int count=0,max=0;
		if(n==1)	System.out.println("0");
		else if(n>1)
		{int i=0,j=1;
			while(j<n)
			{
				if(a[i]>=a[j])	
				{
					count++;
					i++;j++;
				}
				else if(a[i]<a[j])
				{
					i++;
					j++;
					max=Math.max(max,count);
					count=0;
				}
				
				
			}
			max=Math.max(max, count);
			System.out.println(max);
		}
		}
	
	}


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

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

int main() {

    int a;
    string s;

    cin >> a >> s;

    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e6 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
int dp[101][4][4][4] ; // 101*4*4*4 = 6464 (10^5)
/*int soln( int n ,  int s1 , int s2 , int s2 ){

}*/
void solve(){
   int n ;
   cin >> n ;
   // 0 - a , 1 - c , 2 - g , 3 - t
   int A = 0 , C = 1 , G = 2 , T = 3 ;
   // acg , cag , agc , aXcg , acXg these are invalid sequence where X stand for unkonw char
   dp[0][3][3][3] = 1;
   for( int len = 0 ; len < n ; len++){
        for( int i = 0 ; i < 4 ; i++){
            for( int j = 0 ; j < 4 ; j++){
                for( int k = 0 ; k < 4  ; k++){
                    if(dp[i][j][k]==0)  continue ;
                    for( int a = 0 ; a < 4 ; a++){
                         if (a == C && i == G && j == A) continue;
                        if (a == C && i == A && j == G) continue;
                        if (a == G && i == C && j == A) continue;
                        if (a == C && i == G && k == A) continue;
                        if (a == C && j == G && k == A) continue;

                        dp[len + 1][a][i][j] += dp[len][i][j][k];
                        dp[len + 1][a][i][j] %= mod;

                    }
                }
            }
        }
   }
   int ans = 0 ;
   for( int i = 0 ; i < 4 ; i++){
        for( int j = 0 ; j < 4 ; j++){
            for( int k = 0 ;k < 4 ; k++){
                ans += dp[n][i][j][k];
                ans%=mod;
            }
        }
   }
   cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    update - o(1) - log time
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int i,n,m,j;
	cin>>n>>m;
	char arr[n][m];
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			cin>>arr[i][j];
	int cnt = 0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cnt = 0;
			if(arr[i][j]=='#')
			{
				if(i!=0 && arr[i-1][j] != '#')
					cnt++;
				if(j!=0 && arr[i][j-1] != '#')
					cnt++;
				if(i!=n-1 && arr[i+1][j] != '#')
					cnt++;
				if(j!=m-1 && arr[i][j+1] != '#')
					cnt++;
			}
			if(cnt==4)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

//auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](){double x; std::cin >> x; return x;};

double distance_p(const std::vector<double> &, const std::vector<double> &, int);
double distance_chb(const std::vector<double> &, const std::vector<double> &);

int main ()
{
  std::cout << std::setprecision(20);
  std::vector<double> xs, ys;
  int n;

  std::cin >> n;

  for (int i=0; i<n; i++)
    xs.push_back(read());
  for (int i=0; i<n; i++)
    ys.push_back(read());

  println(distance_p(xs, ys, 1));
  println(distance_p(xs, ys, 2));
  println(distance_p(xs, ys, 3));
  println(distance_chb(xs, ys));
}

double distance_p(const std::vector<double> & xs, const std::vector<double> & ys, int p)
{
  auto n = xs.size();
  auto sum = 0.0;

  for (int i=0; i<n; i++)
    {
      sum += std::pow(std::abs(xs.at(i)-ys.at(i)), p);
    }
  return pow(sum, 1.0/p);
}

double distance_chb(const std::vector<double> & xs, const std::vector<double> & ys)
{
  auto max = 0.0;
  for (int i=0; i<xs.size(); i++)
    {
      auto diff = std::abs(xs.at(i)-ys.at(i));
      if (diff > max)
        max = diff;
    }
  return max;
}



Measured memory_bytes: 3496
#include <iostream>
#include<vector>
#include<cstdio>
using namespace std;
class Set{
    public: vector<int> set;
    Set(int n){
        set.resize(n);
        for(int i = 0;i < n;++i){
            set[i] = (1 << 31) - 1;
        }
        
    }
    
    public: void update(int x,int y){
        set[x] = y;
    }
    
    public: int find(int s,int e){
        int min = (1 << 31) - 1;
        for(int i = s;i <= e;++i){
            if(set[i] < min) min = set[i];
        }
        return min;
    }
    
};

int main(void){
    int n,q,x,y,c;
    scanf("%d %d",&n,&q);
    Set set(n);
    for(int i = 0;i < q;++i){
        scanf("%d",&c) ;
        scanf("%d %d",&x,&y);
        if(c==0){
            set.update(x,y);
        }else{
            printf("%d\n",set.find(x,y));
        }
    }
    
}



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

#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main(int argc, char const* argv[])
{
   ll w, h, x, y;
   int ans;
   cin >> w >> h >> x >> y;
   if (2*x == w && 2*y == h) {
      ans = 1;
   } else {
      ans = 0;
   }
   cout << w*h/2.0 << " " << ans << endl;
   return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>

using namespace std;

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

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

int main()
{
	int n;
	double w, h;
	while(scanf("%d,%lf,%lf", &n, &w, &h) != EOF){
		if(w/h/h >= 25.0)
			printf("%d\n", n);
	}

	return 0;
}

Measured memory_bytes: 0
x,y = gets.strip.split(" ").map(&:to_i)
count = "-1 -1 -1"
(0..x).each do |n|
    (0..(x-n)).each do |m|
        l = x - n - m
        count = "#{n} #{m} #{l}" if 10000 * n + 5000 * m + 1000 * l == y
    end
end
print count

Measured memory_bytes: 3836
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL f(LL n, LL x) {
	if (x == 0)return 0;
	auto tmp = f(x, (n - x) % x);
	if (tmp == 0)return x*(2 * (n / x) - 1);
	return x*(2 * (n / x)) + tmp;
}

int main() {
	LL n, x;
	cin >> n >> x;
	x = min(x, n - x);
	cout << n + f(n - x, x) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s = str(input())
    if s[2]==s[3] and s[4]==s[5]:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator >(const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, int cost)
{
	g[from].push_back(Edge{ from, to, cost });
}
int dx[] = { -1, 0, 1, 0 }; int dy[] = { 0, 1, 0, -1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int dir, int h, int w) { return dir*h*w + w*x + y; }

/*--------------------template--------------------*/

vi rev(int p, int h, int w)
{
	//(dir*h+x)*w+y
	int y = p%w;
	p = (p - y) / w;
	int x = p%h;
	int dir = (p - x) / h;
	vi v = { x,y,dir };
	return v;
}

int main()
{
	ll h, w, l;
	while (cin >> h >> w >> l, h)
	{
		Graph g(h*w * 4);
		vs fld(h);
		REP(i, h) cin >> fld[i];
		int st;
		REP(i, h)REP(j,w)
		{
			if (fld[i][j] == 'N') st = place(i, j, 0, h, w);
			if (fld[i][j] == 'E') st = place(i, j, 1, h, w);
			if (fld[i][j] == 'S') st = place(i, j, 2, h, w);
			if (fld[i][j] == 'W') st = place(i, j, 3, h, w);
			if (fld[i][j] != '.' && fld[i][j] != '#') fld[i][j] = '.';
		}
		REP(dir, 4)REP(i, h)REP(j, w)
		{
			if (fld[i][j] == '#') continue;
			int k = 0, cnt = 0;
			int nx = i + dx[dir], ny = j + dy[dir];
			for (; !valid(nx, ny, h, w) || fld[nx][ny] == '#';)
			{
				k++;
				cnt++;
				if (cnt > 10) goto next;
				k %= 4;
				nx = i + dx[(dir + k) % 4]; ny = j + dy[(dir + k) % 4];
			}
			add_edge(g, place(i, j, dir, h, w), place(nx, ny, (dir + k) % 4, h, w), 1);
		next:;
		}
		set<int> memo; vi v; int loop;
		memo.insert(st); v.push_back(st);
		while (1)
		{
			int tmp = v.back();
			int next = g[tmp][0].to;
			if (memo.find(next) != memo.end())
			{
				loop = next;
				break;
			}
			memo.insert(next);
			v.push_back(next);
		}
		int ans;
		if (v.size() > l) ans = v[l];
		else
		{
			int beg = find(ALL(v), loop) - v.begin();
			int len = v.size() - beg;
			l -= beg;
			ans = v[beg + l%len];
		}
		vi ansv = rev(ans, h, w);
		int ax = ansv[0] + 1, ay = ansv[1] + 1;
		char ad;
		switch (ansv[2])
		{
		case 0:
			ad = 'N';
			break;
		case 1:
			ad = 'E';
			break;
		case 2:
			ad = 'S';
			break;
		case 3:
			ad = 'W';
			break;
		}
		cout << ax << " " << ay << " " << ad << endl;
	}
	return 0;
}

Measured memory_bytes: 3468
(set! *unchecked-math* true)
(defn input []
  (let [[N M] (->> (clojure.string/split (read-line) #"\s")
                (map #(Integer/parseInt %)))]
    (list N
      (->> (repeatedly M read-line)
        (sequence
          (comp (map #(clojure.string/split % #"\s"))
            (map (partial mapv #(Integer/parseInt %)))))))))

(defn CoutningRoads [^"[I" Array Rs]
  (doseq [r Rs
          :let [id1 (unchecked-dec-int (r 0))
                id2 (unchecked-dec-int (r 1))
                v1 (unchecked-inc-int (aget ^"[I" Array id1))
                v2 (unchecked-inc-int (aget ^"[I" Array id2))]]
    (aset ^"[I" Array id1 v1)
    (aset ^"[I" Array id2 v2)))

(defn output [^"[I" Array]
  (->> Array
    (transduce (map #(format "%s\n" %)) str "")
    print))

(let [[N Rs] (input)]
  (doto (int-array N (int 0))
    (CoutningRoads Rs)
    (output)))

Measured memory_bytes: 66580
l = list(map(int, list(input())))
n = len(l) + 1
MOD = 10**9+7
dp1 = [0 for _ in range(n)]
dp2 = [0 for _ in range(n)]
dp1[0] = 1
for i in range(1, n):
    if l[i-1] == 1:
        dp1[i] = dp1[i-1] * 2
        dp2[i] = dp1[i-1] + dp2[i-1] * 3
    else:
        dp1[i] = dp1[i-1]
        dp2[i] = dp2[i-1] * 3
    dp1[i] %= MOD
    dp2[i] %= MOD
print((dp1[-1] + dp2[-1]) % MOD)

Measured memory_bytes: 52728
S = input()
flag = True
for i in S[::2]:
  if i == "R" or i == "U" or i == "D":
    continue
  else:
    print("No")
    exit()
for i in S[1::2]:
  if i == "L" or i == "U" or i == "D":
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int n;
    cin >> n;
    int a[n][n];
    REP(i,n){
        REP(j,n){
            cin >> a[i][j];
        }
    }
    Mint<> dp[1 << n];
    dp[0] = 1;
    for(int bit = 0; bit < (1 << n) - 1; bit++){
        int i = __builtin_popcount(bit);
        for(int j = 0; j < n; j++){
            if(a[i][j] == 0 || bit & 1 << j) continue;
            dp[bit | 1 << j] += dp[bit];
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
const int mod = 1000000007;
 
int main() {
    int n;
    cin >> n;
    VS s(n);
    rep(i,n) {
        cin >> s[i];
    }

    SORT(s);
    string tmp = s[0];
    int count = 1;
    for(int i = 1;i < n; i++) {
        if(s[i] != tmp) {
            count++;
            tmp = s[i];
        }
    }

    cout << count << endl;


}

Measured memory_bytes: 9600
s = input()
N = len(s) + 1
l = [0]*N #からのリストN個
for i in range(N-1):
  if s[i] == '<':
    l[i+1] = l[i] + 1
for k in range(N-2,-1,-1):#後ろから逆順で一ずつ降る
  if s[k] == '>':
    l[k] = max(l[k], l[k+1] + 1)
print(sum(l))

Measured memory_bytes: 23336
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e9;
static const int INF = 0x3f3f3f3f;
static const int MOD = 998244353;

int main(){
    
    int n;
    int r,c;
    sc(n);sc(r);sc(c);
    int ans1 = n-r+1;
    int ans2 = n-c+1;
    cout << ans2*ans1;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
from collections import defaultdict
from queue import deque
g = defaultdict(list)

d = [float('inf')] * n
visited = [False] * n
d[0] = 0
def bfs(v):
    s = deque([v])
    visited[v] = True
    while len(s) > 0:
        t = s.pop()
        for c,w in g[t]:
            if not visited[c] and d[c] == float('inf'):
                d[c] = d[t] + w
                visited[c] = True
                s.append(c)
for i in range(n-1):
    s,t,w = map(int, input().split())
    g[s].append((t, w))
    g[t].append((s, w))

bfs(0)
mi = 0
md = 0
for i,k in enumerate(d):
    if md < k:
        mi = i
        md = k
d = [float('inf')] * n
visited = [False] * n
d[mi] = 0
bfs(mi)
print(max(d))

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define EPS 1e-14
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

int main()
{
    int n, c=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+')c++;
        else c--;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256