akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace CsTest
{
    class Program
    {
        static void Main()
        {
            var ab = AtCoder.ReadStringArray();
            var a = ab[0];
            var b = ab[1];

            Console.WriteLine(a == b ? 'H' : 'D');
        }
    }

    public class AtCoder
    {
        public static string[] ReadStringArray() => Console.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
        public static int[] ReadInt32Array() => ReadStringArray().Select(s => int.Parse(s)).ToArray();
        public static long[] ReadInt64Array() => ReadStringArray().Select(s => long.Parse(s)).ToArray();
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		switch(n){
		case 1:
			System.out.println("Hello World");
			break;
		case 2:
			System.out.println(sc.nextInt() + sc.nextInt());

		}


	}

}


Measured memory_bytes: 23252
import fractions

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

l = [0]*n
r = [0]*n

l[0] = a[0]
for i in range(1,n):
  l[i] = fractions.gcd(l[i-1],a[i])
#print(l)

r[n-1] = a[n-1]
for i in range(n-1)[::-1]:
  r[i] = fractions.gcd(r[i+1],a[i])
#print(r)

b = [0]*n
b[0] = r[1]
b[n-1] = l[n-2]
for i in range(1,n-1):
  b[i] = fractions.gcd(l[i-1],r[i+1])
print(max(b))

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int temp = n;
	while(temp) {
		sum += temp%10;
		temp /= 10;
	}
	puts((n % sum == 0) ? "Yes" : "No");
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define ins insert
#define er erase
#define f(i,a,b) for(i=a;i<b;++i)
#define rf(i,a,b) for(i=a;i>=b;--i)
#define tc int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int> 
#define vll vector<ll> 
#define vull vector<ull>
#define vc vector<char>
#define vst vector<string>
#define bs bitset
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b) 
#define lb lower_bound
#define ub upper_bound
#define nl "\n" 
#define sp " "
using namespace std;

//LET'S PLAY THE GAME!!

int main(){
    fast;
    
    int n,x;cin>>n>>x;
    int i,e;vi p(n+1);
    f(i,0,n){
        cin>>e;
        p[i+1]=p[i]+e;
    }
    int ans=ub(all(p),x)-p.begin();
    cout<<ans;
    
    return 0;
}
// AND THE GAME IS OVER!!

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

const int N = 100 * 1001;
int n, dp[N][3], a[N][3];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	dp[n - 1][0] = a[n - 1][0], dp[n - 1][1] = a[n - 1][1], dp[n - 1][2] = a[n - 1][2];
	for (int i = n - 2; 0 <= i; i--) 
		for (int j = 0 ; j < 3; j++) 
			for (int z = 1; z < 3; z++)
				dp[i][j] = max(dp[i][j], a[i][j] + dp[i + 1][(j + z) % 3]); 
	int ans = 0;
	for (int i = 0; i < 3; i++)
		ans = max(ans, dp[0][i]);
	cout << ans << endl;
}

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

int main(){
    string a;
    cin >> a;
    int count = 0;
    for(int i=0;i<a.size();++i){
        if(a[i]=='1'){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0

for i in range(N):
    a=bisect.bisect_left(A,B[i])
    c=N-bisect.bisect_right(C,B[i])
    ans+=a*c

print(ans)

Measured memory_bytes: 23156
import scala.io.StdIn.{readInt,readLine}

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      (1 to n).foreach{ _ =>
        val s = readLine.split(" ").map(_.toInt)
        val x = s(0)*s(4)-s(1)*s(5)-s(2)*s(6)-s(3)*s(7)
        val y = s(0)*s(5)+s(1)*s(4)+s(2)*s(7)-s(3)*s(6)
        val z = s(0)*s(6)+s(2)*s(4)-s(1)*s(7)+s(3)*s(5)
        val w = s(0)*s(7)+s(3)*s(4)+s(1)*s(6)-s(2)*s(5)
        println(x + " " + y + " " + z + " " + w)
      }
    }
  }
}

Measured memory_bytes: 44264
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           System.IO

readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

main :: IO ()
main = remainderReminder

remainderReminder :: IO ()
remainderReminder = do
  nkT :: [Int] <- getLineSpc
  let [n, k] = nkT :: [Int]
  if k /= 0 then do
    m <- newIORef 0
    forM_ [2..n] $ \i -> do
      let (q, r) = n `divMod` i
          add    = q * max 0 (i - k) + max 0 (r - k + 1)
      modifyIORef m (+ add)
    m <- readIORef m
    print m else
    print $ n ^ 2

Measured memory_bytes: 18812
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = input().rstrip()
    ans = 0
    for i in n:
        ans += int(i)
    if ans%9==0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()


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

long long N, K;
vector<long long> A(2e5+5);
vector<long long> Acnt(2e5+5);

int main(){
    
    cin >> N >> K;

    for (int i=1; i<N+1; i++){
        cin >> A.at(i);
    }

    long long pos = 1;
    long long rpos = 1;     
    long long fmove = 0;
    long long rmove = 0;
    long long last_move = 0;

    pos = 1;
    Acnt.at(1) = 1;
    while (1){
        pos = A.at(pos);
        Acnt.at(pos)++;
        if (Acnt.at(pos) == 3){
            rpos = pos;
            break;
        }
    }

    for (int i=1; i<N+1; i++){
        if (Acnt.at(i)==1){
            fmove++;
        }
    }
    for (int i=1; i<N+1; i++){
        if (Acnt.at(i)>1){
            rmove++;
        }
    }

    //  ループに入るまでの移動回数がループより大きい場合、ここで引かないとNG
    last_move = (K-fmove)%rmove;

    if (K > fmove){
        pos = rpos;
        for (int i=0; i<last_move; i++){
            pos = A.at(pos);
        }
    }
    else{
        pos = 1;
        for (int i=0; i<K; i++){
            pos = A.at(pos);
        }
    }

    cout << pos << endl;
    return 0;
}

Measured memory_bytes: 6284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String S = sc.next();
	    
	    int ans = 1000;
	    for (int i=0; i<S.length()-2; i++){
	    	String a= S.substring(i, i+3);
	    	int b = Integer.valueOf(a);
	    	
	    	ans = Math.min(ans, Math.abs(b-753));
	    }
	    
	    System.out.println(ans);
	    sc.close();
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1004][100004];
ll ks(ll v[],ll wt[],ll w,ll n){
	// base case
	
	if(n==0||w==0){
		return 0;
	}
	if(dp[n][w]!=-1) return dp[n][w];
	if(wt[n-1]<=w){
		return dp[n][w]=max(v[n-1]+ks(v,wt,w-wt[n-1],n-1),ks(v,wt,w,n-1));
	}
	else{
		return dp[n][w]=ks(v,wt,w,n-1);
	}
	
}


int main(){
	memset(dp,-1,sizeof(dp));
	ll n,w;
	cin>>n>>w;
	ll wt[n],v[n];
	for(ll i=0;i<n;i++){
		cin>>wt[i]>>v[i];
	}
	cout<<ks(v,wt,w,n);
}

Measured memory_bytes: 784768
#include<cstdio>
#include<cstring>
using namespace std;
int h,t,cnt; 
int main(){  
    char a[100002];
    scanf("%s",a);  
    int t=strlen(a)-1;  
    while(h<t){
    	if(a[h]==a[t]){
	        h++,t--;
	        continue;
	    }
    	if(a[h]!=a[t]){
    		if(a[h]=='x') h++,cnt++;
    		else if(a[t]=='x') t--,cnt++;
    		else{
    			printf("-1");
    			return 0;
			}
		}
	}
	printf("%d",cnt);
    return 0;  
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, st = "";
  cin >> s;
  REP(i,s.size()) {
    if(s[i] == '0') st.push_back('0');
    if(s[i] == '1') st.push_back('1');
    if(s[i] == 'B' && !(st.empty())) st.pop_back();
  }
  cout << st << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
   string S;
   cin >> S;
   int k = S.size();
   int cnt = 0;
   for(int i = 0; i < k; i++){
       if(S[i] == 'o') cnt+=1;
   }
   
   if(cnt + 15 - k >= 8) cout << "YES" << endl;
   else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d; cin>>n>>d;
  long long int x,y; int ans=0;
  for(int i=1;i<=n;i++){
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=d) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3592
from collections import Counter

S = input()
#S = "1"*20000

p = 2019 # 10 と互いに素なのであんまり桁のずれは関係ない？
N = len(S)

# m は各桁の累積和
m = [(int(S[i]) * pow(10, N-i, p)) % p for i in range(N)]

# m の mod 累積和
r = [0] * N
r[0] = m[0]
for ri in range(1, N):
    r[ri] = (r[ri-1] + m[ri]) % p

# この r[i] が一致するような区間が答えになるのでこれをもとめる
c = Counter(r)

ans = 0
for ci in [cv for cv in c.values() if cv >= 2]:
    ans += ci * (ci-1) // 2

if 0 in c.keys():
    ans += c[0]

print(ans)


Measured memory_bytes: 23580
#include<iostream>
using namespace std;
int main() {
	int x;
	while (cin >> x) {
		x %= 39;
		if (x == 0)cout << "3C39";
		else if (x < 10)cout << "3C0" << x;
		else cout << "3C" << x;
		cout << endl;
	}
}

Measured memory_bytes: 3068
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
#define MAX (2000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;

bool prime[MAX + 1];
int dp[15][1121];

int main()
{
	for (int i = 2; i <= MAX; i++){
		prime[i] = true;
	}
	for (int i = 2; i * i <= MAX; i++){
		for (int j = i * i; j <= MAX; j += i){
			prime[j] = false;
		}
	}
	
	dp[0][0] = 1;
	for (int i = 0; i <= 1120; i++){
		if (!prime[i]) continue;
		
		for (int j = 14; j >= 1; j--){
			for (int k = i; k <= 1120; k++){
				dp[j][k] += dp[j - 1][k - i];
			}
		}
	}
	
	int n, k;
	while (scanf("%d %d", &n, &k), n + k){
		printf("%d\n", dp[k][n]);
	}
}

Measured memory_bytes: 1096
h, w, k = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = S.copy()

index = 1
for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            ans[i][j] = str(index)
            index += 1

for i in range(h):
    for j in range(w-1):
        if ans[i][j] != "." and ans[i][j+1] == ".":
            ans[i][j+1] = ans[i][j] 

for i in range(h):
    for j in range(w-1, 0, -1):
        if ans[i][j] != "." and ans[i][j-1] == ".":
            ans[i][j-1] = ans[i][j]

for j in range(w):
    for i in range(h-1):
        if ans[i][j] != "." and ans[i+1][j] == ".":
            ans[i+1][j] = ans[i][j]

for j in range(w):
    for i in range(h-1, 0, -1):
        if ans[i][j] != "." and ans[i-1][j] == ".":
            ans[i-1][j] = ans[i][j]

for l in ans:
    print(" ".join(l))

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

int main() {
    int N;

    cin >> N;
    vector<int> a(N);
    int cnt = 0;
    bool odd1 = false;
    bool odd2 = false;

    for(int i=0; i<N; i++){
        cin >> a.at(i);
    }

    for (int i=0; i<N; i++){
        if (a.at(i) % 2 == 1){
            odd1 = true;
        }
        if ((i+1) % 2 == 1){
            odd2 = true;
        }
        if (odd1 == true && odd2 == true){
            cnt++;
        }
        
        odd1 = false;
        odd2 = false;
    }

    cout << cnt << endl;

}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N;
    int[] A;
    List<int>[] Edge;

    int Len;
    int[] Stack;

    int[] Ans;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
        Edge = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            Edge[i] = new List<int>();
        }

        for (int i = 0; i < N - 1; i++)
        {
            int u = sc.NextInt() - 1;
            int v = sc.NextInt() - 1;
            Edge[u].Add(v);
            Edge[v].Add(u);
        }
        Stack = new int[N];
        for (int i = 0; i < N; i++)
        {
            Stack[i] = int.MaxValue;
        }
        Len = 0;

        Ans = new int[N];
        DFS(0, -1);

        Console.WriteLine(string.Join("\n", Ans));
    }


    void DFS(int pos, int parent)
    {
        // 超えないところ
        int ok = -1;
        int ng = Len;

        while (ng - ok > 1)
        {
            int mid = (ok + ng) / 2;
            if (Stack[mid] < A[pos]) ok = mid;
            else ng = mid;
        }

        int pLen = Len;
        int prev = Stack[ng];

        if (ng >= Len) Len++;
        Stack[ng] = Math.Min(Stack[ng], A[pos]);
        Ans[pos] = Len;
        foreach (var to in Edge[pos])
        {
            if (to == parent) continue;
            DFS(to, pos);
        }
        Len = pLen;
        Stack[ng] = prev;
    }

    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: 83204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
    int a;
    int p;
    int y;
    int t;
}city_s;

int citysort(const void *a, const void *b){
    int city = ((city_s*)a)->p - ((city_s*)b)->p; 
    int year = ((city_s*)a)->y - ((city_s*)b)->y;
    if(city != 0){
        return city;
    }else if(year != 0){
        return year;
    }else{
        return 0;
    }
}

int sortret(const void *A, const void *B){
    return ((city_s*)A)->a - ((city_s*)B)->a;
}

int main(){
    int N, M;
    city_s citynum[110000];
    int i, j, k;
    int tmp, citytmp;

    scanf("%d %d", &N, &M);
    for(i=0; i<M; i++){
        scanf("%d %d", &citynum[i].p, &citynum[i].y);
        citynum[i].a = i;
    }

    qsort(citynum, M, sizeof(city_s), citysort);

    j=1;
    tmp = 1;
    citytmp = 1;

    for(i=0; i<M; i++){
        if(citynum[i].p != citytmp){
            citytmp = citynum[i].p;
            tmp = 1;
        }
        citynum[i].t = tmp;
        tmp++;
    }

    qsort(citynum, M, sizeof(city_s), sortret);

    for(i=0; i<M; i++){
        printf("%012.0lf\n", (double)citynum[i].p*1000000 + citynum[i].t);
    }

    return 0;
}

Measured memory_bytes: 4588
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");

  var S = input[0];
  var N = S.length;
  var c1 = isPalindrome( S );
  var l2 = ( N - 1 ) / 2;
  var S2 = S.substr( 0, l2 );
  var c2 = isPalindrome( S2 );
  var l3 = ( N + 3 ) / 2;
  var S3 = S.substr( l3 - 1 );
  var c3 = isPalindrome( S3 );
  if( c1 * c2 * c3 == 1 ){
    console.log( 'Yes' );
  }else{
    console.log( 'No' );
  }
}

function isPalindrome( s ){
  var l = s.length;
  var n = Math.floor( l / 2 );
  var r = 1;
  for( var i = 0; i < n && r == 1; i ++ ){
    var c1 = s.charAt( i );
    var c2 = s.charAt( l - 1 - i );
    r = ( c1 == c2 ? 1 : 0 );
  }
  
  return r;
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        if((A == 5 || A == 7) && (B == 5 || B == 7)  && (C == 5 || C == 7) && A + B + C == 17)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 35660
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	while (cin >> H >> W >> K, H) {
		vector<string>s(H);
		for (auto &i : s)cin >> i;
		int sy, sx;
		int d;
		int dir[] = { -1,0,1,0,-1 };
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] == 'N') {
					d = 0;
					sy = i, sx = j;
					s[i][j] = '.';
				}
				if (s[i][j] == 'E') {
					d = 1;
					sy = i, sx = j;
					s[i][j] = '.';
				}
				if (s[i][j] == 'S') {
					d = 2;
					sy = i, sx = j;
					s[i][j] = '.';
				}
				if (s[i][j] == 'W') {
					d = 3;
					sy = i, sx = j;
					s[i][j] = '.';
				}
			}
		}
		vector<vector<vector<long long int>>>turn(H, vector<vector<long long int>>(W, vector<long long int>(4, MOD*MOD)));
		int loop = MOD;
		turn[sy][sx][d] = 0;
		int cnt = 1;
		while (cnt<=K) {
			bool con = true;
			while (con) {
				int ny = sy + dir[d];
				int nx = sx + dir[d + 1];
				if (ny < 0 || nx < 0 || ny >= H || nx >= W || s[ny][nx] == '#') {
					d++;
					d %= 4;
					continue;
				}
				con = false;
			}
			sy += dir[d];
			sx += dir[d + 1];
			if (turn[sy][sx][d] == MOD * MOD) {
				turn[sy][sx][d] = cnt++;
			}
			else {
				loop = cnt - turn[sy][sx][d];
				break;
			}
		}
		string ans = "NESW";
		int a, b;
		char c;
		int box = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < 4; k++) {
					if (turn[i][j][k]!=MOD*MOD&&(K - turn[i][j][k]) % loop == 0&&box<=turn[i][j][k]) {
						a = i + 1, b = j + 1, c = ans[k];
						box = turn[i][j][k];
					}
				}
			}
		}
		cout << a << " " << b << " " << c << endl;
	}
}


Measured memory_bytes: 3900
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
vl a;
vl accum;
ll getsum(int r,int l){//lからrまでの和
  if(l>0){
    return accum[r]-accum[l-1];
  }else{
    return accum[r];
  }
}
int searchborder(int r,int l){//二分探索で「左側の右端」のindexを求める
  if(l>r){
    cout<<"error"<<endl;
    return -1;
  }
  int tmpl=l;
  int tmpr=r;
  int mid=(l+r)/2;
  while(tmpl!=mid){
    //cout<<" l "<<l << " r "<<r<<" mid "<<mid<<endl;
    if(getsum(mid,l)<=getsum(r,mid+1)){
      tmpl=mid;
    }else{
      tmpr=mid;
    }
    mid=(tmpr+tmpl)/2;
  }
  return mid;
}
int main(void){
  int n;
  cin>>n;
  a=vl(n);
  rep(i,n){
    cin>>a[i];
  }
  accum = vl(n);
  accum[0]=a[0];
  rep(i,n-1){
    accum[i+1]=accum[i]+a[i+1];
  }
  ll ans=llMAX;
  for(int i=1;i<n-2;i++){//全体を二分したときの左側の右端がi
  //cout<<"r";
    int lborder=searchborder(i,0);//四分したときの一番左の区間の右端のindex
    int rborder=searchborder(n-1,i+1);//四分したときの右から3番目の区間の右端のindex

    vl nums;//4つの区間の和を入れる

    nums.pb(getsum(lborder,0));
    nums.pb(getsum(i,lborder+1));
    nums.pb(getsum(rborder,i+1));
    nums.pb(getsum(n-1,rborder+1));
    ll tmpmax=0;
    ll tmpmin=llMAX;
    for(auto j:nums){
      tmpmax=max(j,tmpmax);
      tmpmin=min(j,tmpmin);
    }
    ans=min(ans,tmpmax-tmpmin);
    nums.clear();
    //cout<<"e";

    //一つずらしたときの場合を考える


    if(lborder+1<i){
      nums.pb(getsum(lborder+1,0));
      nums.pb(getsum(i,lborder+2));
      nums.pb(getsum(rborder,i+1));
      nums.pb(getsum(n-1,rborder+1));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"i";
    }
    if(rborder+1<n-1){
      nums.pb(getsum(rborder+1,i+1));
      nums.pb(getsum(n-1,rborder+2));
      nums.pb(getsum(lborder,0));
      nums.pb(getsum(i,lborder+1));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"a";
    }
    if(rborder+1<n-1 && lborder+1<i){
      nums.pb(getsum(rborder+1,i+1));
      nums.pb(getsum(n-1,rborder+2));
      nums.pb(getsum(lborder+1,0));
      nums.pb(getsum(i,lborder+2));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"s";
    }
    //cout<<"now "<<tmpmax-tmpmin<<" max "<<tmpmax<<" min "<<tmpmin<<endl;
    //ans=min(ans,tmpmax-tmpmin);
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int i,j,cnt=0;
    string s,t;
    cin>>s>>t;
    int n=s.size();
    rep(i,n){
        if (s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
   
   
   
   
   
   
	return 0;
}


Measured memory_bytes: 3784
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int i,j,k,n;
    cin>>n;
    string a,b,c;
    cin>>a>>b;
    
    for(i=0;i<n;i++)
    {
        c+=a[i];
        c+=b[i];
    }
    cout<<c;
    

    return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, K;
	std::vector<int> X;
	std::cin >> N >> K;
	X.resize(N);
	for (auto& x : X) {
		std::cin >> x;
	}
	
	int result = 0;
	for (auto x : X) {
		if (x < K - x) {
			result += x;
		} else {
			result += K - x;
		}
	}
	result *= 2;
	std::cout << result << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        for(int i=1; ; i++){
            int x = scanner.nextInt();
            if(x == 0){
                break;
            }else{
                System.out.println("Case " + i + ": " + x);
            }
                
            
        }
    }
}


Measured memory_bytes: 42680
#include<iostream>
using namespace std;
int main(void){
    char a[3];
    int ans = 0;
    cin >> a[0] >> a[1] >> a[2];
    if(a[0]=='R'){
        if(a[1]=='R'){ 
            if(a[2]=='R'){
                ans=3;
            }else{
                ans=2;
            } 
        }else{
            ans=1;
        }
    }else if(a[1]=='R'){
            if(a[2]=='R'){
                ans=2;
            }else{
                ans=1;
            }
    }else if(a[2]=='R'){
        ans=1;
    }
    cout << ans;
}

Measured memory_bytes: 3632
import heapq

#N is numbers of BAITO, M is limit of days
N,M=map(int,input().split())
 
i=0
inp ={}
while i<N:
  readTime,inCome=map(int,input().split())
  if readTime in inp:
    inp[readTime].append(-inCome)
  else:
    inp[readTime]=[-inCome]
  
  i=i+1
 
#print(inp)  
 
result=0
pool=[]
heapq.heapify(pool)
i=1
while i<=M:
  if i in inp:
    for k in inp[i]:
      heapq.heappush(pool,k)
  if len(pool)>0:
    result=result-heapq.heappop(pool)
  i=i+1
 
print(result)


Measured memory_bytes: 72280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  ll n;
  cin >> n;
  ll ans = 1;
  REP(i,n+1){
    ans = ans * i % mod;
  }
  cout << ans << endl;
} 






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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);
    vector<ll> b(a);
    for(ll x : a){
        b.emplace_back(x);
    }

    ll inv = 0;
    ll inv2 = 0;
    for(int i = 0; i < 2*n; ++i){
        for(int j = i+1; j < 2*n; ++j){
            if(b[i] > b[j] and (i < n and j >= n)) ++inv2;
            else if(b[i] > b[j] and j < n) ++inv;
        }
    }
    inv %= MOD;
    inv2 %= MOD;
    // eee(inv);
    // eee(inv2);
    ll x;
    if(k%2){
        x = (k-1)/2*k%MOD;
    }
    else{
        x = k/2*(k-1)%MOD;
    }
    ll ans = (k*inv%MOD + x*inv2%MOD)%MOD;
    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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; }

//https://qiita.com/drken/items/a14e9af0ca2d857dad23

//N=1の時に自分で対応しなきゃいけないから注意
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll my_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

ll gcd(ll a,ll b) {if(a%b==0) return(b); else return(gcd(b,a%b));}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  
  auto prime_list=prime_factorize(N);
  ll sz=prime_list.size();
  
  
  ll m;
  vector<ll> M(sz);
  rep(i,sz){
    ll a,ex; tie(a,ex)=prime_list[i];
    M[i]=my_pow(a,ex);
  }
  vector<ll> vec(0);
  //rep(i,M.size()) {if(i!=0) cout<<" "; cout<<M[i];} cout<<'\n'; 
  rep(i,1<<sz){
    vector<ll> R(sz);
    rep(j,sz){
      if(i&1<<j) R[j]=0;
      else R[j]=M[j]-1;
    }
    ll x;
    auto p=crt(R,M); tie(x,m)=p;
    //cout<<x<<'\n';
    if(x<=0) x+=m;
    vec.push_back(x);
  }
  sort(vec.begin(),vec.end());
  //for(auto v:vec) cout<<v<<'\n';
  
  while(true){
    for(auto &num:vec){
      //cout<<num<<" "<<num*(num+1)%(2*N)<<'\n';
      ll sN=2*N/gcd(2*N,num);
      if((num+1)%sN==0) {cout<<num<<'\n'; return 0;}
      num+=N;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3728
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

T=list(ns())
ans=[]
for i in range(len(T)):
    if(T[i]=='?'):
        ans.append('D')    
    else:
        ans.append(T[i])

print(''.join(ans))

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

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

  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a >= h && b >= w) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

vector<vector<ll>> tree;
vector<bool> used;
void solve(long long N, std::vector<long long> a, std::vector<long long> b){

    ll len=0;
    ll last=-1;
    deque<ll> q;
    deque<pll> qq;
    if(N==1)goto first;
    tree.resize(N);
    used.resize(N);
    fill(used.begin(),used.end(),false);
    REP(N-1){
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }
    q.push_back(0);
    used[0]=true;
    while(!q.empty()){
        ll tmp=q.front();q.pop_front();
        for (auto &&i : tree[tmp])
        {
            if(used[i]==false){
                last=i;
                q.push_back(i);
                used[i]=true;
            }
        }
    }
    qq.push_back(pll(last,0));
    fill(used.begin(),used.end(),false);
    used[last]=true;
    while(!qq.empty()){
        pll tmp=qq.front();qq.pop_front();
        for (auto &&i : tree[tmp.first])
        {
            if(used[i]==false){
                len=max(len,tmp.second+1);
                qq.push_back(pll(i,tmp.second+1));
                used[i]=true;
            }
        }
    }
    if((len-1)%3)goto first;
    else goto second;
    first:
    cout<<"First"<<endl;
    return;
    second:
    cout<<"Second"<<endl;
    return ;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--;
        b[i]--;
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 19184
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-20 16:34:12
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n;

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

    cin >> n;
    cout << 360 / __gcd(n , 360ll) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 3608
# %%time
from collections import Counter, deque
n = int(input())
s = input()


# n = 4000
# np.random.seed(1)
# s = np.random.randint(0, 3, n)
# s = (s)

c = Counter(s)
c = list(c.values())
if len(c) == 3:
    ans = c[0] * c[1] * c[2]
else:
    ans = 0
# print(ans)
if ans > 0:
    for k in range(n):
        for a in range(1, (n - k)//2 + 1):
            if k + 2 * a >= n:
                continue
            x, y,  = s[k], s[k + a]
            
            if x != y:
                z = s[k + 2 * a]
                if y != z:
                    if z != x:
                        ans -= 1

print(ans)

Measured memory_bytes: 68868
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Queue {

	private String[] names;
	private int[] times;
	private int head;
	private int tail;
	public Queue(int size) {
		names = new String[size + 1];
		times = new int[size + 1];
	}

	public void enqueue(String name, int time) {
		names[tail] = name;
		times[tail] = time;
		if (tail++ == names.length - 1) {
			tail = 0;
		}
	}

	public int dequeue() {
		if (head == names.length - 1) {
			head = 0;
			return names.length - 1;
		}
		return head++;
	}

	public boolean isEmpty() {
		return head == tail;
	}

	public String getName(int index) {
		return names[index];
	}

	public int getTime(int index) {
		return times[index];
	}
}

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int n = Integer.parseInt(strs[0]);
		int q = Integer.parseInt(strs[1]);
		Queue queue = new Queue(n);
		StringBuilder sb = new StringBuilder();
		int sumTime = 0;
		for (int i = 0; i < n; i++) {
			strs = br.readLine().split(" ");
			int time = Integer.parseInt(strs[1]);
			if (time <= q) {
				sumTime += time;
				sb.append(strs[0] + " " + sumTime + "\n");
			} else {
				sumTime += q;
				queue.enqueue(strs[0], time - q);
			}
		}
		while (!queue.isEmpty()) {
			int entryIdx = queue.dequeue();
			String name = queue.getName(entryIdx);
			int time = queue.getTime(entryIdx);
			if (time <= q) {
				sumTime += time;
				sb.append(name + " " + sumTime + "\n");
			} else {
				sumTime += 	q;
				queue.enqueue(name, time - q);
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 62420
class SegmentTree:
    def __init__(self, data, default=0, func=max):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1

        return self._func(res_left, res_right)

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)


def f(tup1,tup2):
    tot=tup1[1]+tup2[1]
    if tup1[2]==1 and tup2[0]==1:
        tot+=1
    a=tup1[0]
    b=tup2[2]
    return (a,tot,b)



n,q=map(int,input().strip().split(" "))
s=input()
ar=[]
for i in s:
    if i=="A":
        ar.append((0,0,1))
    elif i=="C":
        ar.append((1, 0, 0))
    else:
        ar.append((0,0,0))
defa=(0,0,0)
seg=SegmentTree(ar,defa,f)
for _ in range(q):
    a,b=map(int,input().strip().split(" "))
    k=seg.query(a-1,b)
    print(k[1])






Measured memory_bytes: 93296
from collections import defaultdict


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    s = len(set(a_list))
    if (len(a_list) - s) % 2 != 0:
        print(s - 1)
    else:
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14948
N, D = map(int, input().split(" "))
lis = [1]*N
range_ = (2 * D) + 1

sho   = len(lis) // range_
amari = len(lis) %  range_

ninzu = amari // range_

if amari == 0:
  print(sho)
else:
  print(sho + 1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    char x = s.charAt(0);
    char y = s.charAt(2);
    if (x > y) {
      System.out.println('>');
    } else if (x == y) {
      System.out.println('=');
    } else {
      System.out.println('<');
    }

  }
}

Measured memory_bytes: 35720
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,m;
    cin >> n >> m;
    vector<int64> a(n);
    for (int64 i=0; i<n; i++) cin >> a[i];
    int64 sum = accumulate(a.begin(), a.end(), 0LL);

    int64 cnt = 0;
    for (int64 i=0; i<n; i++) {
        if (a[i]*4*m >= sum) cnt++;
    }

    cout << (cnt>=m? "Yes" : "No") << endl;
}

/*
 * sum / 4m < a[i]
 * sum < a[i] * 4m;
 */

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

int main(){
	int n, t = 100000;
	cin >> n;
	for( int i = 0; i < n; ++i){
		t = 1.05 * t;
		t = (t/1000)*1000 + ((t % 1000 != 0) ? 1000 : 0);
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,M;
	cin>>N>>M;
	VI map(M,0);
	REP(i,N){
		int K;
		cin>>K;
		REP(j,K){
			int a;
			cin>>a;
			map[a-1]++;
		}
	}
	ll ans=0;
	REP(i,M)
		if(map[i]==N)ans++;
	cout<<ans<<endl;
	return 0;
}




















Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x[3000],y[3000];
	int i =0;
	int swap;
	for(i=0;i<100000;++i){
		cin>>x[i]>>y[i];
		if(x[i]==0&&y[i]==0) break;
		if(x[i]>y[i]){
			swap=x[i];
			x[i]=y[i];
			y[i]=swap;
		}
	}
	for(int j=0;j<i;++j) cout<<x[j]<<" "<<y[j]<<endl;
return 0;
}

Measured memory_bytes: 3016