akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
  public static class Deck {

    HashMap<String, HashSet<Integer>> cards = new HashMap<String, HashSet<Integer>>();

    public Deck() {
      // Spades, Hearts, Clubs, Diamonds
      this.cards.put("S", generateSet());
      this.cards.put("H", generateSet());
      this.cards.put("C", generateSet());
      this.cards.put("D", generateSet());
    }

    public static HashSet<Integer> generateSet() {
      HashSet<Integer> set = new HashSet<Integer>();
      for (int i = 1; i <= 13; i++) {
        set.add(i);
      }
      return set;
    }

    public void removeCard(String suit, int rank) {
      HashSet<Integer> set = this.cards.get(suit);
      set.remove(rank);
    }

    public void displayRemaining_helper(String suit) {
      HashSet<Integer> set = this.cards.get(suit);
      List<Integer> remainingCards = new ArrayList<Integer>(set);
      Collections.sort(remainingCards);
      for (int rank : remainingCards) {
        System.out.println(suit + " " + rank);
      }
    }

    public void displayRemaining() {
      this.displayRemaining_helper("S");
      this.displayRemaining_helper("H");
      this.displayRemaining_helper("C");
      this.displayRemaining_helper("D");
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    Deck cards = new Deck();
    int n = s.nextInt();
    for (int i = 0; i < n; i++) {
      cards.removeCard(s.next(), s.nextInt());
    }
    s.close();
    cards.displayRemaining();
  }
}



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

#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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n, m;
    vector<ll> p;

    cin >> n >> m;

    ll tmp;
    REP(i, n){
      cin >> tmp;
      p.PB(tmp);
    }

    ll total = accumulate(ALL(p), 0);
    sort(ALL(p), greater<ll>());

    ll t = 0;
    REP(i, m){
      if (4*m*p[i] < total){
        cout << "No" << endl;
        return 0;
      }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include<cstdio>
#include <string>
#include <cwchar>
#include <stdio.h>
#include <ctype.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 || i%5==0 || i%15==0)
		{
			continue;
		}
		sum+=i;
	}
	cout<<sum<<endl;
}

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

bool isok(long long n) {
  vector<int> v;
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  auto v2 = v;
  reverse(v2.begin(), v2.end());
  return v == v2;
}

int main() {
  int A, B;
  cin >> A >> B;
  int res = 0;
  for (int n = A; n <= B; ++n) if (isok(n)) ++res;
  cout << res << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main()
{
	int num, i, j, buf, count = 0;
	int a[10][10] = { 0 };

	scanf("%d",&num);
	for (i = 1; i <= num; i++) {
		buf = i;
		while (buf >= 10) buf /= 10;
		a[buf][i % 10]++;
	}
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			count += a[i][j] * a[j][i];
		}
	}
	printf("%d\n", count);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    ll n;cin >> n;
    ll ans=0;
    rep2(i,1,n+1){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
{-# LANGUAGE BangPatterns #-}

import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List

getAsInt :: IO [Int]
getAsInt =  unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getAsIntLine :: Int -> IO [[Int]]
getAsIntLine n = replicateM n getAsInt

getAsIntArray2D :: Int -> Int -> IO (UArray (Int,Int) Int)
getAsIntArray2D n m = U.listArray ((1,1),(n,m)) . concat <$> getAsIntLine n


main :: IO ()
main = main2

main1 :: IO ()
main1 = do
  [n,w] <- getAsInt
  wvs <- getAsIntArray2D n 2
  let result = solve1 wvs n w
  print $ maximum $ map (\x -> result U.! (n,x)) [0..w]

main2 :: IO ()
main2 = do
  [n,w] <- getAsInt
  wvs <- map (\[x,y] -> (x, y)) <$> getAsIntLine n
  let solve = solve2'
      result = solve w wvs
  print $ maximum $ map (\x -> result U.! x) [0..w]

solve1 :: UArray (Int,Int) Int -> Int -> Int -> UArray (Int,Int) Int
solve1 wvs n' w' = runSTUArray $ do
  dp <- newArray ((0,0),(n',w')) 0
  forM_ [(n_,w_) | n_ <- [1..n'], w_ <- [0..w']] $ \(n,w) -> do
    let wtmp = wvs U.! (n,1)
        vtmp = wvs U.! (n,2)
    if w - wtmp < 0
      then readArray dp (n-1,w) >>= writeArray dp (n,w)
      else do
        a <- readArray dp (n-1,w)
        b <- readArray dp (n-1,w-wtmp)
        writeArray dp (n,w) $ max a (b+vtmp)
  return dp

solve2 :: Int -> [(Int,Int)] -> UArray Int Int
solve2 w' [] = U.listArray (0,w') $ repeat 0
solve2 w' ((wtmp,vtmp):xs) = let a = solve2 w' xs
                                 f w = if w - wtmp >= 0
                                       then max (a U.! w) (a U.! (w - wtmp) + vtmp)
                                       else a U.! w
                             in U.array (0,w') [(w, f w) | w <- [0..w']]

solve2' :: Int -> [(Int,Int)] -> UArray Int Int
solve2' !w' [] = U.listArray (0,w') $ repeat 0
solve2' !w' ((!wtmp,!vtmp):(!xs)) = let !a = solve2 w' xs
                                        f !w = if w - wtmp >= 0
                                               then max (a U.! w) (a U.! (w - wtmp) + vtmp)
                                               else a U.! w
                                    in U.array (0,w') [(w, f w) | !w <- [0..w']]

solve3 :: Int -> [(Int,Int)] -> UArray Int Int
solve3 w' = foldr f (U.listArray (0,w') $ repeat 0)
  where f (wtmp,vtmp) a = let g w = if w - wtmp >= 0
                                    then max (a U.! w) (a U.! (w - wtmp) + vtmp)
                                    else a U.! w
                          in U.array (0,w') [(w, g w) | w <- [0..w']]

solve3' :: Int -> [(Int,Int)] -> UArray Int Int
solve3' !w' = foldr f (U.listArray (0,w') $ repeat 0)
  where f (!wtmp,!vtmp) !a = let g !w = if w - wtmp >= 0
                                        then max (a U.! w) (a U.! (w - wtmp) + vtmp)
                                        else a U.! w
                          in U.array (0,w') [(w, g w) | !w <- [0..w']]


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(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 + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;
	string s;
	cin>>s;

	ll n = s.length();
	forn(i,0,n)
	{
		cout<<'x';
	}

	return 0;
}

Measured memory_bytes: 256
import heapq

def solve(scores):
  sm = sum(scores)
  if(sm % 10 != 0): return sm
  heapq.heapify(scores)
  while scores:
    mn = heapq.heappop(scores)
    sm -= mn
    if(sm % 10 != 0) : return sm
    sm += mn
  else:
    return 0     

N = input()
S = [input() for i in range(N)]
heapq.heapify(S)

while S:
  arr = [i for i in S]
  best = solve(arr)
  if(best > 0):
    print best
    break
  heapq.heappop(S)
else:
  print 0

Measured memory_bytes: 2692
n = int(input())
a = list(map(int, input().split()))[::-1]

min_ans = 2
max_ans = 2

for i in range(n):
    min_ans = -((-min_ans) // a[i]) * a[i]
    
for i in range(n):
    max_ans = (max_ans// a[i]) * a[i] +a[i] - 1

a = a[::-1]
tmp_ans = min_ans
tmp_ans2 = max_ans
for i in range(n):
    tmp_ans = (tmp_ans // a[i]) * a[i]
    tmp_ans2 = (tmp_ans // a[i]) * a[i]
    
if tmp_ans == 2 and tmp_ans2 == 2:
    print(min_ans, max_ans)
else:
    print(-1)

Measured memory_bytes: 63856
Module Module1

    Sub Main()
        Dim input As String
        Dim suuzisu As Integer

        Dim bingocard(2, 2) As Integer


        For i As Integer = 0 To 2
            Dim tempsuretsu(2) As String
            tempsuretsu = Console.ReadLine().Split(" "c)
            bingocard(i, 0) = CType(tempsuretsu(0), Integer)
            bingocard(i, 1) = CType(tempsuretsu(1), Integer)
            bingocard(i, 2) = CType(tempsuretsu(2), Integer)
        Next

        suuzisu = CType(Console.ReadLine(), Integer)

        Dim checkkazu(suuzisu - 1) As Integer

        For i As Integer = 0 To suuzisu - 1
            checkkazu(i) = CType(Console.ReadLine(), Integer)
        Next

        '--ここから穴あけ

        For k As Integer = 0 To checkkazu.Length - 1

            For bingorow As Integer = 0 To 2
                For bingocol As Integer = 0 To 2
                    If bingocard(bingorow, bingocol) = checkkazu(k) Then
                        bingocard(bingorow, bingocol) = -1
                    End If
                Next
            Next

        Next

        Dim bingoflg As Boolean = False
        '--ここからチェック
        For t As Integer = 0 To 2
            If bingocard(t, 0) = bingocard(t, 1) AndAlso
               bingocard(t, 1) = bingocard(t, 2) AndAlso
               bingocard(t, 0) = -1 Then
                bingoflg = True
            End If

            If bingocard(0, t) = bingocard(1, t) AndAlso
               bingocard(1, t) = bingocard(2, t) AndAlso
               bingocard(2, t) = -1 Then
                bingoflg = True
            End If
        Next

        If bingocard(0, 0) = bingocard(1, 1) AndAlso
               bingocard(1, 1) = bingocard(2, 2) AndAlso
               bingocard(2, 2) = -1 Then
            bingoflg = True
        End If

        If bingocard(0, 2) = bingocard(1, 1) AndAlso
               bingocard(1, 1) = bingocard(2, 0) AndAlso
               bingocard(2, 0) = -1 Then
            bingoflg = True
        End If


        If bingoflg Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If



    End Sub




End Module


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
vector<string> S;

void dfs(string s, char c) {
    if (s.length() == N) {
        S.push_back(s);
        return;
    }

    REP(i, s.length()) {
        s.push_back(s[i]);
        dfs(s, c);
        s.pop_back();
    }
    s.push_back(c);
    dfs(s, c + 1);
}

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

    dfs("", 'a');

    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    REP(i, S.size()) {
        cout << S[i] << endl;
    }
    return 0;
}

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

int main(void) {
    string s;
    int64_t oddcnt=0,evencnt=0;
    int64_t oddmax = 0, evenmax = 0;
    int64_t wcost,bcost;
    cin >> s;

    for(int i=0;i<s.size();i++) {
        if(i%2) {
            if(s[i] == '1') oddcnt++;
            oddmax++;
        } else {
            if(s[i] == '1') evencnt++;
            evenmax++;
        } 
    }

    // wbwbwの場合のコスト
    wcost = evenmax-evencnt+oddcnt;
    // bwbwbの場合のコスト
    bcost = oddmax -oddcnt + evencnt;

    cout << min(wcost,bcost) << endl;
    return 0;
}


Measured memory_bytes: 512
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll dx[8]={-1,-1,-1,1,1,1,0,0};
  ll dy[8]={-1,0,1,-1,0,1,-1,1};
  ll n,m;
  cin>>n>>m;
  char v[n][m];
  rep(i,n) rep(j,m) cin>>v[i][j];
  rep(i,n){
    rep(j,m){
      if(v[i][j]=='#'){
        cout<<'#';
      }else{
        ll tmp=0;
        rep(k,8){
          ll a=i+dy[k];
          ll b=j+dx[k];
          if(a<0 || n<=a || b<0 || m<=b) continue;
          if(v[a][b]=='#') tmp++;
        }
        cout<<tmp;
      }
    }
    cout<<endl;
  }
  
  
  
  
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n && n) {
    vector<VI> a(n, VI(n));
    REP(i, 0, n) REP(j, 0, n) cin >> a[i][j];
    vector<VI> fl(n, VI(n));
    REP(i, 0, n) {
      int mi = 1e8;
      REP(j, 0, n) mi = min(mi, a[i][j]);
      REP(j, 0, n) fl[i][j] |= mi == a[i][j] ? 1 : 0;
    }
    REP(j, 0, n) {
      int ma = 0;
      REP(i, 0, n) ma = max(ma, a[i][j]);
      REP(i, 0, n) fl[i][j] |= ma == a[i][j] ? 2 : 0;
    }
    int c = 0;
    REP(i, 0, n) REP(j, 0, n) {
      if (fl[i][j] == 3) c = a[i][j];
    }
    cout << c << endl;
  }
}



Measured memory_bytes: 3128
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
############################  
from math import floor

N=int(input())
p= floor(N**0.5)

ans=0
for i in range(1,p+1):
  if N%i==0:
    s = i
    t = N//i-1
    #print(s,t)
    u = N//i
    v = i-1
    #print(u,v)
    if s<t:
      ans += t
    if u<v:
      ans += v
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(int i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
int n,arr[10],A,B,C;
int func(int index,int a,int b,int c){
    if(index==n){
        if(min(a,min(b,c))>0)return (abs(a-A)+abs(b-B)+abs(c-C))-30;
        else       return 1e9;
    }
    return min(func(index+1,a,b,c),10+min(func(index+1,a+arr[index],b,c),min(func(index+1,a,b+arr[index],c),func(index+1,a,b,c+arr[index]))));
}
int main(){
    fast;
    int a,b,c;
    cin>>n>>A>>B>>C;
    f(i,0,n)cin>>arr[i];
    cout<<func(0,0,0,0);

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
 int n;
 cin>>n;
 vector<int> a(n),b(n);
 for(int i=0;i<n;i++){
   cin>>a[i];
   b[i]=a[i];
 }
  sort(b.begin(),b.end());
  int a_max=b[n-1];
  int a_second=b[n-2];
  if(a_max==a_second){
    for(int i=0;i<n;i++){
      cout<<a_max<<endl;
    }
  }
  else {
    for(int i=0;i<n;i++){
      if(a[i]==a_max)cout<<a_second<<endl;
      else cout<<a_max<<endl;
    }
  }
}
    

Measured memory_bytes: 3200
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int x;
	cin >> x;

	int actions = 1;
	int angle = x;
	while (angle) {
		angle += x;
		angle %= 360;
		++actions;
	}

	cout << actions << "\n";

	return 0;

}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import numpy as np
S = input()
n = len(S)
l = np.zeros(n, dtype=int)
DNA = ['A', 'G', 'C', 'T']

if S[0] in DNA:
  ll = [1]
else:
  ll = [0]

for i in range(1, n):
  if S[i] in DNA:
    ll.append(ll[i-1]+1)
  else:
    ll.append(0)

print(max(ll))


Measured memory_bytes: 12484
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int h,w;cin>>h>>w;
  vector<vector<char>> f(h,vector<char>(w));  
  vector<vector<bool>> t(h,vector<bool>(w,true));
  rep(i,h)rep(j,w)cin>>f[i][j];
  //rep(i,h)rep(j,w)cout<<f[i][j];
  rep(i,h){
    int cnt=0;
    rep(j,w)if(f[i][j]=='.')cnt++;
    if(cnt==w)rep(j,w)t[i][j]=false;
  }
  rep(j,w){
    int cnt=0;
    rep(i,h)if(f[i][j]=='.')cnt++;
    if(cnt==h)rep(i,h)t[i][j]=false;
  }
  rep(i,h){
    bool flag=false;
    rep(j,w)if(t[i][j]){
      cout<<f[i][j];
      flag=true;
    }
    if(flag)cout<<endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll h, w, d, q;

int main() {
    cin >> h >> w >> d;
    M<int, Pii> a;
    REP(i, h) REP(j, w) {
        int x; cin >> x;
        a[x] = {i, j};
    }

    Vl cost(h*w+1, 0);
    REP2(i, d+1, h*w+1) {
        Pii bef = a[i], aft = a[i-d];
        cost[i] = cost[i-d] + abs(bef.first - aft.first) + abs(bef.second - aft.second);
    }

    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        cout << cost[r] - cost[l] << '\n';
    }

    return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		if(n==1)
		{
			printf("Hello World\n");
			continue;
		}
		if(n==2)
		{
			int a, b;

			scanf("%d%d", &a, &b);
			printf("%d\n", a+b);
		}
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long

int solve(int a, int b, int c){
	return __gcd(a, __gcd(b, c));
}
int32_t main(){ fast;
	int k, answer = 0; cin>>k;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j<=k; j++){
			for(int t = 1; t <= k; t++){
				answer += solve(i, j, t);
			}
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3652
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] exp = br.readLine().split(" ");
        int[] stack = new int[199];
        int top = 0;

        for (int i = 0; i < exp.length; i++) {
            if (exp[i].equals("+")) {
                stack[top - 2] += stack[top - 1];
                top--;
            } else if (exp[i].equals("-")) {
                stack[top - 2] -= stack[top - 1];
                top--;
            } else if (exp[i].equals("*")) {
                stack[top - 2] *= stack[top - 1];
                top--;
            } else {
                stack[top] = Integer.parseInt(exp[i]);
                top++;
            }
        }

        System.out.println(stack[0]);
    }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
	string s[3] = { "Sunny","Cloudy","Rainy" };
	string c;
	cin >> c;
	if (c == s[0]) {
		cout << s[1] << endl;
	}
	else if (c == s[1]) {
		cout << s[2] << endl;
	}
	else {
		cout << s[0] << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
bool hanten[101010];
bool henused[101010];
struct edge{ll to,num;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void add_edge(ll s, ll t, ll n){
        G[s].emplace_back((edge){t, n});
        G[t].emplace_back((edge){s, n}); //無向ならON
    }

    void dfs(ll v=0, ll p=-1){
        used[v]=true;
        for(auto E : G[v]){
            if(!used[E.to]){
                dfs(E.to, v);
            }
        }
        for(auto E : G[v]){
            ll num=E.num;
            if(henused[num]) continue;
            henused[num]=true;
            if(E.to==p) continue;
            cout<< v+1 << " "<< E.to+1 <<"\n";
            hanten[v]=!hanten[v];
        }
        if(p==-1) return;
        if(hanten[v]){
            cout<< v+1 << " "<< p+1 <<"\n";
        }
        else{
            cout<< p+1 <<" "<<v+1 <<"\n";
            hanten[p]=!hanten[p];
        }
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(M);
    vector<ll> B(M);
    graph g(N);
    rep(i,M){
        cin>>A[i]>>B[i];
        g.add_edge(A[i]-1,B[i]-1,i);
    }
    if(M%2!=0) dame;
    g.dfs();
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define ll long long
#define MOD 998244353

int n, k, a[100005];
ll dp[100005];

int main()
{
    for(int i = 0; i < 100005; i++)
        dp[i] = INF;
    cin>>n>>k;
    for(int i = 0; i < n; i++)
        cin>>a[i];

    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k && i+j<n; j++)
        {
            dp[i+j] = min(dp[i+j], dp[i] + abs(a[i]-a[i+j]));
        }
    }

    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1408
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
import sys
ary = [a,b,c,d,e]
for i in ary:
    for j in ary:
        if abs(i-j) > k:
            print(":(")
            sys.exit()
print("Yay!")


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


struct FenwickTree {
  static const int SIZE = 60000;
  int tree[SIZE + 10];
  FenwickTree() { memset(tree, 0, sizeof(tree)); }
  void add(int index, int value) {
    for (index += SIZE / 2; index < SIZE + 1; index += (index & -index)) {
      tree[index] += value;
    }
  }
  int sum(int index) {
    int ret = 0;
    for (index += SIZE / 2; index > 0; index -= (index & -index)) {
      ret += tree[index];
    }
    return ret;
  }
};

int n;
ll l, m, r;
ll seq[110];
FenwickTree ftree[2];

int main() {
  while (scanf("%d %lld %lld %lld", &n, &l, &m, &r) > 0) {
    m *= 2;
    r *= 2;
    REP(i, n) {
      scanf("%lld", &seq[i]);
    }
    ftree[0] = FenwickTree();
    ftree[1] = FenwickTree();
    ftree[0].add(0, 1);
    ftree[0].add(1, -1);
    REP(i, n) {
      int prev = i & 1;
      int next = prev ^ 1;
      ftree[next] = FenwickTree();
      ll l1 = -l * seq[i];
      ll r1 = -r * seq[i];
      ll l2 = r * seq[i];
      ll r2 = l * seq[i];
      FOREQ(w, -m, m) {
        if (ftree[prev].sum(w) == 0) { continue; }
        ll l, r;
        l = max(-m - 1, min(m + 1, l1 + w));
        r = max(-m - 1, min(m + 1, r1 + w));
        ftree[next].add(l, 1);
        ftree[next].add(r + 1, -1);
        l = max(-m - 1, min(m + 1, l2 + w));
        r = max(-m - 1, min(m + 1, r2 + w));
        ftree[next].add(l, 1);
        ftree[next].add(r + 1, -1);
      }
      bool ok = false;
      FOREQ(w, -m, m) {
        if (ftree[next].sum(w) >= 1) { ok = true; }
        //putchar(ftree[next].sum(w) > 0 ? 'o' : 'x');
      }
      //puts("");
      if (!ok) { goto ng; }
    }
    puts("Yes");
    continue;
ng:
    puts("No");
  }
}

Measured memory_bytes: 2012
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N,M,C; cin >> N>>M>>C;
	ll ans = 0;
	VLL  B(M);
	vector<vector<int>> A(N);
	for (int i = 0;i < M;i++) cin >> B[i];
	for (int i = 0;i < N;i++) {
		A[i].resize(M);
		for (int j = 0;j < M;j++) cin >> A[i][j];
	}
	for (int i = 0;i < N; i++) {
		A[i][0] *= B[0];
		for (int j = 1;j < M;j++) {
           A[i][0]+=A[i][j]*B[j];
		}
		if (A[i][0] + C > 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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


    int N;
    cin >> N;
    int p[N], x[N + 1];
    memset(x, 0, sizeof(x));
    rep(i, 0, N) {
        cin >> p[i];
        x[p[i]] = i;
    }

    int a[N], b[N];
    rep(i, 0, N) {
        a[i] = 30000 * (i + 1) + x[i + 1];
        b[i] = 30000 * (N - i + 1);
    }

    rep(i, 0, N - 1) cout << a[i] << " ";
    cout << a[N - 1] << endl;
    rep(i, 0, N - 1) cout << b[i] << " ";
    cout << b[N - 1] << endl;



}


Measured memory_bytes: 896
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int dp[100010][14] = {0};
int amari[10];

signed main(){
    string s;
    cin >> s;
    rep(i,10)amari[i] = i;
    dp[0][0] = 1;
    int n = s.size();

    rep(i,n){
        if(s[n-1-i] == '?'){
            rep(k,10){
                rep(j,13){
                    dp[i+1][(j+amari[k])%13] += dp[i][j];
                    dp[i+1][(j+amari[k])%13] %= MOD;
                }
            }
        }else{
            int d = s[n-1-i]-'0';
            rep(j,13){
                dp[i+1][(j+amari[d])%13] += dp[i][j];
                dp[i+1][(j+amari[d])%13] %= MOD;
            }
        }
        // rep(j,13)cerr << dp[i+1][j] << " ";
        // cerr << endl;
        rep(j,10){
            amari[j] = (amari[j]*10)%13;
        }
    }
    cout << dp[n][5] << endl;
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc135.contest.atcoder.jp/tasks/abc135_a

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  ll n;
  cin>>n;
  vector<ll> f(n+1);
  for(int i=2;i<=n;i++){
    f[i]++;
    for(int j=2;j*i<=n;j++){
      f[j*i]++;
    }
  }

  ll ans=0;
  for(ll i=1;i<=n;i++){
    //cout<<i<<" "<<f[i]<<endl;
    ans+=i*(f[i]+1);
  }
  cout<<ans<<"\n";


  return 0;
}


Measured memory_bytes: 81344
#include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
//void scan(string &s) {for (char c; !isspace(c = gcu()); s += c);}
bool scan(int &n) {n = in(); int c = gcu(); return (c != EOF)? ungetc(c, stdin), true: false;}
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int f(int n, int s, int j) {
	if (j > 10)
		return 0;
	if (n == 0)
		return s ? 0 : 1;
	int c = 0;
	for (int i = j; i <= 9; i++)
		if (s - i >= 0)
			c += f(n - 1, s - i, i + 1);
	return c;
}

int main() {
	int n, s;
	while (scan(n) && scan(s) && (n || s)) {
		out(f(n, s, 0), '\n');
	}
}


Measured memory_bytes: 2348
var MAX_VALUE = 1000;

var inputRaw = require('fs').readFileSync('/dev/stdin', 'utf8')
var rows = inputRaw.trim().split('\n');
var row1 = rows[0].split(' ').map(Number);
var N = row1[0];
var W = row1[1];
var list = rows.slice(1).map(r => r.split(' ').map(Number));
var dp = Array.from({ length: N + 1 }, _ => Array( N * MAX_VALUE + 1).fill(0));
dp[0] = Array( N * MAX_VALUE + 1).fill(Infinity)
dp[0][0] = 0;
// console.log(dp);

function solve() {

  for (var i = 0; i < N; i++) {
    for (var j = 0; j <= N * MAX_VALUE; j++) {
      if (list[i][1] <= j) {
        var a = dp[i][j - list[i][1]] + list[i][0];
        var b = dp[i][j];
        dp[i + 1][j] = Math.min(a, b);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  var result = 0;
  for (var i = 0; i <= N * MAX_VALUE; i++) if (dp[N][i] <= W) result = i;
  return result;
}

console.log(solve());


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

using namespace std;

void solve(){
	long long int n; cin>>n;
	vector<long long int> p(n+1,1);
	//for(int i = 1; i <= n; i++) cout << p[i] << " ";
	for(int i = 1; i <= n; i++){
		if(p[i]){
			for(int j = 2; i*j <= n; j++){
				p[i*j]++;
			}
		}
	}
	//for(int i = 1; i <= n; i++) cout << p[i] << " ";
	long long int ans = 0;
	for(long long int i = 1; i <= n; i++){
		ans += (i*p[i]);
	}
	cout << ans << "\n";
}
int main() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 81340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int s = (new Scanner(System.in)).nextInt();
		int hour = s/3600;
		int min = (s%3600)/60;
		int sec = (s%3600)%60;
		
		System.out.printf("%d:%d:%d\n", hour, min, sec);
	}

}

Measured memory_bytes: 26352
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

int h,w;

int main(){
	cin>>h>>w;
	vvi a(h,vi(w));
	for(int i=0;i<h;i++){
		bool flag=0;
		int num;
		for(int j=0;j<w;j++){
			char t;
			cin>>t;
			if(t=='c'){
				flag=1;
				num=0;
			}
			if(!flag) a[i][j]=-1;
			else{
				a[i][j]=num;
				num++;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j) cout<<' ';
			cout<<a[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<int> A(N);
	vector<int> B(M);
	for(int i = 0;i < N;i++) {
		cin >> A.at(i);
	}
	for(int i = 0;i < M;i++) {
		cin >> B.at(i);
	}
	bool answer = false;
	for(int i = X + 1;i <= Y;i++) {
		bool count = true;
		for(int j = 0;j < N;j++) {
			if(A.at(j) >= i) {
				count = false;
			}
		}
		for(int j = 0;j < M;j++) {
			if(B.at(j) < i) {
				count = false;
			}
		}
		if(count == true) {
			answer = true;
		}
	}
	if(answer == true) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 201000;
int n;
vector<int> d[MAX];

int naj;
int odl;
void dfs(int v,int p,int od){
  if(odl < od){
    naj = v;
    odl = od;
  }
  for(int el:d[v])if(el != p){
    dfs(el, v, od + 1);
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    d[a].PB(b);
    d[b].PB(a);
  }
  int ak = 0;
  R(i,3){
    odl = -1;
    dfs(ak, -1, 1);
    ak = naj;
  }
  debug(odl);
  if(odl % 3 == 2){
    cout << "Second\n";
  }else{
    cout << "First\n";
  }
}


Measured memory_bytes: 18176
import sys

fact = [1]
p = 10**9 + 7

def fact1(n,m):
    for i in range(1,n+m+1):
        new_fact = fact[i-1]*i %p
        fact.append(new_fact)

#ax+by=1の解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2

    return [w[0],w[1]]
#aの逆元(mod m) a,mは互いに素
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return x%m
if __name__ == "__main__":
    x, y = (int(i) for i in input().split())
    if (x+y)%3 != 0 or 2*x < y or 2*y < x:
        print(0)
        exit()
    n = int((2*y-x)/3)
    m = int((2*x-y)/3)
    fact1(n,m)
    n1 = mod_inv(fact[n],p)
    m1 = mod_inv(fact[m],p)
    ans = fact[n+m] * (n1*m1 %p) % p
    print(ans)


Measured memory_bytes: 29484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=1e18;
ll dp[200005][3], arr[200005];
int n;
ll f(int i, int skip){
	if(i>=n){
		if(skip<=1) return 0ll;
		return -INF;
	}
	if(dp[i][skip]!=-INF) return dp[i][skip];
	dp[i][skip]=f(i+2, skip)+arr[i];
	if(skip>0) dp[i][skip]=max(dp[i][skip], f(i+1, skip-1));
	return dp[i][skip];
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		for(int j=0; j<3; j++)
			dp[i][j]=-INF;
	}
	ll ans=f(0, (n&1)?2:1);
	if(n&1){
		ll tmp=0ll, mn=INF;
		for(int i=0; i<n; i+=2){
			tmp+=arr[i];
			if(mn>arr[i]) mn-=arr[i];
		}
		tmp-=mn;
		ans=max(ans, tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16132
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
    io
  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;

}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int N_MAX = 100000;
const int K_MAX = 1000;
int N, K;
int x[N_MAX];
int y[N_MAX];
char c[N_MAX];
int a[2 * K_MAX][K_MAX];
int s[2 * K_MAX + 1][K_MAX + 1];

int f(int x1, int y1, int x2, int y2)
{
    return s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1];
}

int main(void)
{
    cin >> N >> K;
    REP(i, N) cin >> x[i] >> y[i] >> c[i];
    REP(i, N) {
        x[i] %= 2 * K;
        y[i] %= 2 * K;
        if (y[i] >= K) {
            if (x[i] >= K) {
                x[i] -= K;
                y[i] -= K;
            } else {
                x[i] += K;
                y[i] -= K;
            }
        }
        if (c[i] == 'W') {
            if (x[i] < K) {
                x[i] += K;
            } else {
                x[i] -= K;
            }
        }
        a[x[i]][y[i]]++;
    }
    /*
    REP(i, 2 * K) REP(j, K) {
        printf("a[%d][%d] = %d\n", i, j, a[i][j]);
    }
    */
    REP(i, 2 * K) s[i][0] = 0;
    REP(j, K) s[0][j] = 0;
    FOR(i, 1, 2 * K + 1) FOR(j , 1, K + 1) {
        s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i - 1][j - 1];
        // printf("s[%d][%d] = %d\n", i, j, s[i][j]);
    }
    int result = 0;
    REP(i, K) REP(j, K) {
        int t;
        t = f(0, 0, i, j) + f(i, j, i + K, K) + f(i + K, 0, 2 * K, j);
        amax(result, t);
        t = f(0, j, i, K) + f(i, 0, i + K, j) + f(i + K, j, 2 * K, K);
        amax(result, t);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 16768