akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

#include <bits/stdc++.h>
using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号

const int VV = 222222;
const int INF = 1e8;
int V, M;
vector<edge> G[VV];
int d[VV];

void dijkstra(int s) {
   // 最短距離firstが小さい順に取り出せるようにする
   priority_queue<P, vector<P>, greater<P>> que;
   fill(d, d + V, INF); // 距離全てをINFで初期化
   d[s] = 0; // スタート地点を0で初期化
   que.push(P(0, s)); // キューに初期位置のコスト、初期位置をpush

   while (que.size()) {
      P p = que.top(); que.pop(); // p: 今の{最短距離、頂点番号}
      int v = p.second; // 今の頂点番号
      if (d[v] < p.first) continue; // 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離
      for (int i = 0; i < G[v].size(); i++) { // 今の頂点に隣接する頂点を調べる
         edge e = G[v][i];
         if (d[e.to] > d[v] + e.cost) { // 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト
            d[e.to] = d[v] + e.cost; // 歴代最小距離の更新
            que.push(P(d[e.to], e.to)); // 更新した遷移先の頂点をキューに突っ込む
         }
      }
   }
}

int main() {
   cin >> V >> M;
   rep (i, M) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back({b, 1});
      G[b].push_back({a, 1});
   }

   dijkstra(0);

   if (d[V-1] == 2) {
      puts("POSSIBLE");
   } else {
      puts("IMPOSSIBLE");
   }

   return 0;
}

Measured memory_bytes: 15592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector a(n,vector<int>(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    int ans=INF;
    rep(S,1<<n){
        vector<int> now(m,0);
        int cnt=0;
        rep(i,n){
            if(S & 1<<i){
                rep(j,m){
                    now[j]+=a[i][j];
                }
                cnt+=c[i];
            }
        }
        bool flag=true;
        rep(j,m){
            if(now[j]<x) flag=false;
        }
        if(flag) chmin(ans,cnt);
    }
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3652
n = int(input())
x_ = list(map(int,input().split()))

if n ==1:
    print(0)
else:
    cnt = 0
    res_ = []
    for i in range(100):
        cnt = 0
        for j in range(len(x_)):
            cnt += (x_[j] - i)**2
        res_.append(cnt)

    print(min(res_))


Measured memory_bytes: 3060
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#x = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
l = len(a)
p = 0
for i in range(l):
    b = a[:i]
    for z in range(l):
        c = a[z:]
        d = ''.join([b,c])
        if 'keyence' == d : j(1)
j(0)

Measured memory_bytes: 5272
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
import collections
import itertools
import operator


class UnionFind:
    def __init__(self, x):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)
        self.size = collections.defaultdict(lambda: 1)
        if x is not None:
            for elem in range(x+1):
                _, _, _ = self.parent[elem], self.rank[elem],self.size[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.are_same(x,y):
            xx = self.size[x]
            yy = self.size[y]
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += xx
            else:
                self.parent[y] = x
                self.size[x] += yy
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def Size(self,x):
        return self.size[self.find(x)]

    def are_same(self, x, y):
        '''print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))'''
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]


h,w = m()
uf = UnionFind(h*w-1)
s = [list(input()) for i in range(h)]


for i in range(h):
    for j in range(w):
        if i == h - 1 and j == w - 1:
            continue
        elif i == h - 1:
            if s[i][j] != s[i][j+1]:
                uf.unite(i*w + j,i*w + j+1)
        elif j == w - 1:
            if s[i][j] != s[i+1][j]:
                uf.unite(i*w + j,(i+1)*w + j)
        else:
            if s[i][j] != s[i+1][j]:
                uf.unite(i*w + j,(i+1)*w + j)
            if s[i][j] != s[i][j+1]:
                uf.unite(i*w + j,i*w + j+1)
kkk = list(uf.grouper())
ans = 0

for i in range(len(kkk)):
    black = 0
    white = 0
    for j in kkk[i]:
        if s[j//w][j%w] == ".":
            white += 1
        else:
            black += 1
    ans += black*white
print(ans)






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

class Main {

  public static void main(String args[]) throws IOException{
	  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	  String[] string =  br.readLine().split(" ");
      int n = Integer.parseInt (string[0]);
	  int Quantum = Integer.parseInt(string[1]);

	  Queue queue = new Queue();
	  queue.initialize();

	  for(int i = 0;i < n; i++){
		  String date =  br.readLine();
		  queue.enqueue(date);
	  }

	  int pasttime = 0;
	  while( queue.isEmpty() == false){
          String[] tmpstring = queue.dequeue().split(" ");
          //System.out.println(tmpstring[0]+ " " + tmpstring[1]);
          int tmptime = Integer.parseInt(tmpstring[1]);

          if( tmptime > Quantum ){
              pasttime += Quantum;
              String time = String.valueOf( tmptime - Quantum);
              queue.enqueue(tmpstring[0]+" "+time);

          }
          else{
        	  pasttime += tmptime;
        	  System.out.println(tmpstring[0]+" "+pasttime);
          }
	  }

 }
}

class Queue{
    int head , tail;
    int MAX = 100000;
    String[] Q = new String[MAX];


    void initialize(){
    	head = tail = 0;
    }

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

    boolean isFull(){
    	return  head == (tail + 1) % MAX;
    }

    void enqueue(String x){
    	if( isFull() ){
    		System.out.println(" ??¨?????????????????????????????????");
    	}
    	 Q[tail] = x;

    	if(tail + 1 == MAX){
    		 tail = 0;
    	}else{
    		 tail++;
    	}

    }

    String dequeue(){
    	if( isEmpty() ){
    		System.out.println(" ??¨???????????¢?????????????????????");
    	}
    	String x = Q[head];

    	if(head + 1 == MAX){
    		head = 0;
   	    }else{
   	     head++;
   	    }
        return x;
    }
}

Measured memory_bytes: 74920
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ab: [usize; if n==1 {0} else {2}],
    }
    if n == 1 {
        println!("Hello World");
    } else {
        println!("{}", ab[0] + ab[1]);
    }
}


Measured memory_bytes: 4352
import scala.collection.mutable
import scala.io.StdIn

object Main extends App {

  val (n, m) = readIntPair
  val (l, r) = (1 to n).splitAt((n-1) / 2)
  val first = if (n % 2 == 1) m else m - 1
  var set = new mutable.TreeSet[Int]()

  var f = 1
  var s = n

  for (i <- 1 to m) {
    while (set.contains(s - f) || s - f == n - s + f) s -= 1
    set += s - f
    set += n - s + f
    assert(f < s)
    println(s"$f $s")
    f += 1
    s -= 1
  }

//  l.reverse.take(first).zip(r).foreach { case (x , y) =>
//    println(s"$x $y")
//  }

//  if (n % 2 == 0)
//    println(s"1 ${n-1}")


  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }

  def readIntArr = StdIn.readLine().split(" ").map(_.toInt)
}

//1 2 3 4 5 6 7 8






Measured memory_bytes: 70512
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,n) for(int i=0;i<n;i++)
#define For1(i,n) for(int i=1;i<=n;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
//#define int long long
/*/-----------------------------Code begins----------------------------------/*/

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  vector<int> cost(n+k,INT_MAX);
  cost[0]=0;
  for(int i=0;i<n-1;i++)
  {
    for(int j=1;j<=k;j++)
    { if(i+j<n)
      cost[i+j]=min(cost[i+j],cost[i]+abs(v[i+j]-v[i]));} }
  cout<<cost[n-1];
}

















Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    int G;
    cin >> G;
    vector<int> p(D), c(D);
    rep(i, 0, D) { cin >> p[i] >> c[i]; }

    int ans = INF;
    rep(mask, 0, 1 << D) {
        int score = 0;
        int cnt = 0;
        rrep(i, 0, D) {
            if (mask >> i & 1) {
                score += c[i];
                score += (i + 1) * p[i] * 100;
                cnt += p[i];
            }
        }
        rrep(i, 0, D) {
            if (!(mask >> i & 1)) {
                rep(j, 0, p[i] - 1) {
                    if (score >= G) break;
                    score += (i + 1) * 100;
                    cnt++;
                }
            }
        }
        if (score >= G) ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
char w[8][8];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0},s[8][8],q[4];
//ツ湘」ツ、ツ可コツ、ツ右ツ、ツ債カ
void func(int y,int x){
	s[y][x]=0;
	for(int i=0;i<4;i++)
	if(y+dy[i]>=0&&y+dy[i]<8&&x+dx[i]>=0&&x+dx[i]<8)
	if(s[y+dy[i]][x+dx[i]]==1){
		
		q[i]++;
		func(y+dy[i],x+dx[i]);
	}
}
int main(){
	while(scanf("%s",w[0])!=EOF){
		for(int i=1;i<8;i++)
			scanf("%s",w[i]);
		for(int i=0;i<8;i++)
		for(int j=0;j<8;j++)
		s[i][j]=w[i][j]-'0';
		
		for(int i=0;i<4;i++)
			q[i]=0;
		for(int i=0;i<8;i++)
		for(int j=0;j<8;j++)
		if(s[i][j]==1)
		func(i,j);
		if(q[0]==1&&q[1]==1&&q[2]==1)
	cout<<'A'<<endl;
else if(q[0]==3)
	cout<<'B'<<endl;
else if(q[2]==3)
	cout<<'C'<<endl;
else if(q[0]==2&&q[3]==1)
	cout<<'D'<<endl;
else if(q[0]==1&&q[2]==2)
	cout<<'E'<<endl;
else if(q[0]==2&&q[2]==1)
	cout<<'F'<<endl;
else if(q[0]==1&&q[2]==1&&q[3]==1)
	cout<<'G'<<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] ingredients = new double[n];
		for(int i=0;i<n;i++){
			ingredients[i] = sc.nextDouble();
		}
		Arrays.sort(ingredients);
		double answer = (ingredients[0]+ingredients[1])/2;
		for(int i=2;i<n;i++){
			answer = (answer+ingredients[i])/2;
        }
        System.out.println(answer);
	}
}

Measured memory_bytes: 24532
import fractions
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
N = int(input())
A = list(map(int, input().split()))
 
l = 1
for a in A:
    l = lcm(l, a)
 
ans = 0
for a in A:
    ans += l // a
 
print(ans % (10**9 + 7))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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


int main(){
	
	int a, b, c;cin >> a >> b >> c;
	int cou = 0;
	
	for(int i = 111;i >= 0;i--){
		if(a % i == 0 && b % i == 0)cou++;
		if(cou == c){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}


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

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

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int vec[h][w];
  int sum=0,sumb=0,a;
  for(int i=0;i<n;i++){
    cin>>a;
    sum+=a;
    for(int j=sumb;j<sum;j++){
      vec[j/w][j%w]=i+1;
    }
    sumb=sum;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2==1){
        cout<<vec[i][w-j-1]<<" ";
      }
      else{
        cout<<vec[i][j]<<" ";
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    } 
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int ans = 0;
    rep(i, k) {
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

ll f0n(ll n){
    if((n+1)%4==0) return 0;
    if((n+1)%4==2) return 1;
    if((n+1)%4==1) return n;
    if((n+1)%4==3) return 1^n;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = f0n(a-1)^f0n(b);
    cout << ans << endl;

}

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

int main() {
	int x; cin >> x;
	cout << x * x * x << endl;
}

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

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int> > dp(h,vector<int>(w,0)),a(h,vector<int>(w,0));
	int ans =0;
	rep(i,h)rep(j,w){
		cin>>a[i][j],dp[i][j]=1-a[i][j];
		if(a[i][j]==0)ans=1;
	}
	rep(i,h-1)rep(j,w-1)
		if(!a[i+1][j+1]){
		dp[i+1][j+1] = min(dp[i][j],min(dp[i+1][j],dp[i][j+1]))+1;
		ans = max(ans,dp[i+1][j+1]*dp[i+1][j+1]);
		}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 18080
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n,p;
while(cin>>p){
long long x[p];
for(i=0;i<p;i++)cin>>x[i];
sort(x,x+p);m=10000000000000000;
for(j=x[0];j<=x[p-1];j++)
{ k=0;
    for(i=0;i<p;i++){
l=abs(x[i]-j);
k+=(l*l);
}
    if(k<m) m=k;
}
cout<<m<<endl;
}
 return 0;
}


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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N][4];
int dp[N][4];
int n, k;

int f(int idx, int act){
	
	if(idx==n) return 0;	
	if(dp[idx][act]!=-1) return dp[idx][act];
	int ans = 0;

	if(act==0){
		ans = max(ans, arr[idx][act] + f(idx+1, 1));
		ans = max(ans, arr[idx][act] + f(idx+1, 2));
	}
	else if(act==1){
		ans = max(ans, arr[idx][act] + f(idx+1, 0));
		ans = max(ans, arr[idx][act] + f(idx+1, 2));
	}
	else if(act==2){
		ans = max(ans, arr[idx][act] + f(idx+1, 0));
		ans = max(ans, arr[idx][act] + f(idx+1, 1));
	}

	return dp[idx][act] = ans;
}

void solve()
{
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			cin >> arr[i][j];
		}
	}

	int op1 = f(0, 0);
	int op2 = f(0, 1);
	int op3 = f(0, 2);

	cout << max({op1, op2, op3}) << endl;
}			 

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    while(t--){
    	solve();
    }
	starboy1299();
}




Measured memory_bytes: 15232
#include <iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	while (H && W) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W ; j++) {
				if (i == 0 || i == H-1 || j == 0 || j == W-1)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a + b >= 24){
      System.out.println(a + b -24);
    }
    else
      System.out.println(a + b);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    ll X;
    cin >> X;
    vector<ll> C(N,0);
    vector<vector<ll>> A(N, vector<ll>(M, 0));
    for(ll i=0;i<N;i++){
        cin>>C[i];
     for(ll j=0;j<M;j++){
         cin>>A[i][j]
     ;}
    ;}
    ll ans=INF;
    for(ll bit=0;bit<(1<<N);bit++){
        vector<ll> rikai(M,0);
        ll money=0;
        for(ll i=0;i<N;i++){
            if(bit&(1<<i)){
              for(ll j=0;j<M;j++){
                  rikai[j]+=A[i][j]
              ;}
              money+=C[i];
            }
        ;}
        ll check=1;
        for(ll i=0;i<M;i++){
            if(rikai[i]<X){
                check=0;break;
            }
        ;}
        if(check)ans=min(ans,money);
    ;}
    if(ans==INF){
        cout<<-1<<endl;return 0;
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main(void){
    int H,N;
    cin>>H>>N;
    int ans=0;
    REP(i,N){
        int a;cin>>a;
        ans+=a;
    }
    if(H-ans<=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <utility>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

typedef struct {
    int from, to;
    int cost;
} edge;

int main() {
    while (true) {
        int b_goal[2];
        int n_bases, n_roads, b_start;
        cin >> n_bases >> n_roads >> b_start >> b_goal[0] >> b_goal[1];

        if (n_bases == 0) break;

        map< int, vector<edge> > edges;
        map< int, vector<edge> > redges;

        while (n_roads--) {
            int b_from, b_to, cost;
            cin >> b_from >> b_to >> cost;
            edge e = { b_from, b_to, cost };
            edges[b_from].push_back(e);
            redges[b_to].push_back(e);
        }

        map<int, int> cost_from_start;
        for (int b = 1; b <= n_bases; ++b) {
            cost_from_start[b] = INT_MAX;
        }

        queue<edge> q;

        {
            vector<edge> ee = edges[b_start];
            for (size_t i = 0; i < ee.size(); ++i) {
                q.push(ee[i]);
            }
        }

        cost_from_start[b_start] = 0;
        for (; !q.empty(); q.pop()) {
            edge e = q.front();

            int new_cost = cost_from_start[e.from] == INT_MAX ? INT_MAX : cost_from_start[e.from] + e.cost;
            if (new_cost < cost_from_start[e.to]) {
                cost_from_start[e.to] = new_cost;

                vector<edge> ee = edges[e.to];
                for (size_t i = 0; i < ee.size(); ++i) {
                    q.push(ee[i]);
                }
            }
        }

        map<int, vector<int> > costs_from_goal;
        for (int b = 1; b <= n_bases; ++b) {
            costs_from_goal[b] = vector<int>(2, INT_MAX);
        }

        for (int I = 0; I <= 1; I++) {
            vector<edge> ee = redges[b_goal[I]];
            for (size_t i = 0; i < ee.size(); ++i) {
                q.push(ee[i]);
            }

            costs_from_goal[b_goal[I]][I] = 0;
            for (; !q.empty(); q.pop()) {
                edge e = q.front();

                int new_cost = costs_from_goal[e.to][I] == INT_MAX ? INT_MAX : costs_from_goal[e.to][I] + e.cost;
                if (new_cost < costs_from_goal[e.from][I]) {
                    costs_from_goal[e.from][I] = new_cost;

                    vector<edge> ee = redges[e.from];
                    for (size_t i = 0; i < ee.size(); ++i) {
                        q.push(ee[i]);
                    }
                }
            }
        }

        int min = INT_MAX;
        for (int b = 1; b <= n_bases; ++b) {
            if (cost_from_start[b] == INT_MAX) continue;
            if (costs_from_goal[b][0] == INT_MAX) continue;
            if (costs_from_goal[b][1] == INT_MAX) continue;

            int v = cost_from_start[b] + costs_from_goal[b][0] + costs_from_goal[b][1];
            if (v < min) {
                min = v;
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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

int main(){
    ll n;
    cin>>n;
    ll ans=INF;
    for(ll i=1;i<=n/2;++i){
        ll a=i;
        ll b=n-i;
        ans = min(ans, keta(a)+keta(b));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                             
#include <cmath>                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  double x1, y1, x2, y2;                                                        
  cin >> x1 >> y1 >> x2 >> y2;                                                  
  double xdiff = x2-x1;                                                         
  double ydiff = y2-y1;                                                         
  cout << fixed;                                                                
  cout.precision(8);                                                            
  cout << hypot(xdiff,ydiff) << endl;                                           
}                         

Measured memory_bytes: 3268
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

char ans[510][510];

signed main() {
    string pat = "RYGB";
    int H, W, d; cin >> H >> W >> d;
    rep(i,0,H) {
        rep(j,0,W) printf("%c", pat[ 2*( ((i+j)/d)%2 ) + ((i-j+510*d)/d)%2]);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B;
  cin >> A >> B;

  int t = min(A, B);
  int r = 16 - 2*t;
  A -= t;
  B -= t;
  //cout << A << " " << B << " " << r << endl;
  if(A > 0){
    if(max(0,r-1)/2 >= A) cout << "Yay!" << endl;
    else cout << ":(" << endl;
  }else{
    if(max(0,r-1)/2 >= B) cout << "Yay!" << endl;
    else cout << ":(" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>

const double PI = 3.14159265358979323846;
using namespace std;

int main()
{
	int L, S, Hour, Minute;
	double ArgH, ArgM,Arg;
	long double Lgth,Ans;

	cin >> L >> S >> Hour >> Minute;

	ArgM = 2 * PI / 60 * Minute;
	ArgH = 2 * PI / 12 * Hour + 2 * PI / 12 / 60 * Minute;
	
	Arg = ArgM - ArgH;

	Lgth = L * L + S * S - 2*L * S * cos(Arg);
	Ans = sqrt(Lgth);
	cout << setprecision(10)<<Ans << endl;

	return 0;
}

Measured memory_bytes: 4152
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int a, b;
  int c = 0;
  
  while ( cin >> a >> b )
    {
      if ( a == 0 && b == 0 ) break;
      
      vector<int> ret;

      for ( auto y = a; y <= b; ++y )
        {
          if ( y % 400 == 0 || ( y % 100 != 0 && y % 4 == 0 ) )
            ret.push_back( y );
        }

      if ( c++ ) cout << endl;

      if ( ret.size() == 0 )
        cout << "NA" << endl;
      else
        for ( auto it = ret.begin(); it != ret.end(); ++it )
          cout << *it << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1228
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var maxStudentsCnt int

	fmt.Scanf("%d", &maxStudentsCnt)

	var anticStudents = make([]int, maxStudentsCnt)
	var answers = make([]string, maxStudentsCnt)

	for index := 0; index < maxStudentsCnt; index++ {
		fmt.Scan(&anticStudents[index])
		answers[anticStudents[index] - 1] = strconv.Itoa(index + 1);
	}

	fmt.Println(strings.Join(answers, " "))
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
const int N = 1e9 + 5;


void solve() {
	ll a, b, n;
	cin >> a >> b >> n;
	if (a == 1) {
		cout << 0;
		return;
	}

	if (n >= b) {
		n = b - 1;
	}
	cout << (a * n) / b - a*(n / b);

}
int main() {

	FASTIO;



	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3608
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e6+3; //AREGLAAAAAAAAR!!!!
int a[MAXN];
int main(){
	int n;
	ri(n);
	int cu=0,dos=0,im=0;
	FOR(i,0,n){
		ri(a[i]);
		if(a[i]%4==0) cu++;
		else if(a[i]%2==0) dos++;
		else im++;
	}
	while(im>1){
		im--;
		cu--;
	}
	if(dos && im) cu--;
	
	if(cu<0) printf("No");
	else printf("Yes");

}


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

int main(void) {
  char G[200][200];
  bool visited[200][200];
  int W, H;
  string str;
  
  while(cin >> H >> W) {
    if(W==0 && H==0) break;
    for(int i=0; i<H; i++) {
      cin >> str;
      for(int j=0; j<W; j++) {
	G[i][j] = str[j];
	visited[i][j] = false;
      }
    }
    
    int x=0, y=0;
    while(1) {
      if(visited[y][x]) { cout << "LOOP" << endl; break; }
      
      visited[y][x] = true;
      if(G[y][x] == '>') x++;
      else if(G[y][x] == 'v') y++;
      else if(G[y][x] == '^') y--;
      else if(G[y][x] == '<') x--;
      else if(G[y][x] == '.') { cout << x << " " << y << endl; break; }
    }

  }
  
  return 0;
}

Measured memory_bytes: 1252
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;

using namespace std;

int dp[1000001],dpodd[1000001];

int main(){

  long ii,jj,kk;
  vector<int> ret;

  //ポロック予想
  int n;
  n = -1;



  for(ii=0;ii<1000001;ii++){
    dp[ii] = INF;
    dpodd[ii] = INF;
  }
      
  dp[0] = 0;
  dpodd[0] = 0;

  int y;

  for(ii=1;;ii++){
    y = ii*(ii+1)*(ii+2)/6;

    if(y>=1e6){
    //if(y>=21){
      break;
    }

    for(jj=y;jj<1000001;jj++){
      //for(jj=y;jj<=40;jj++){
    
      dp[jj] = min(dp[jj],dp[jj-y] + 1);
    
      if(y%2 == 1){
        dpodd[jj] = min(dpodd[jj],dpodd[jj-y] + 1);
      }
    
    }
    //for(jj=1;jj<=40;jj++){
    //  cout << dp[jj] << "\t";
    //}
    //cout << endl;
  }

    
  
  while(n != 0){
    cin >> n;
    if(n!=0){
      cout << dp[n] << " " << dpodd[n] << endl;
    }

  }


  return 0;
}



Measured memory_bytes: 10888
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using namespace boost;
main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (auto&& hh : h) {
    cin >> hh;
  }
  sort(h.begin(),  h.end());
  int64_t m = 1L << 40;
  for (auto i : irange(k-1, n)) {
    m = min(h[i] - h[i-k+1], m);
  }
  cout << m << endl;
}
  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define tc int t; cin>>t; while(t--)
#define eki int n; cin>>n;
#define loop for(int i=0; i<n; i++)
int main()
{  
    int a, b;
    cin>>a>>b;
    if(a!=1 && b!=1)
    cout<<1<<endl;
    else if(a!=2 && b!=2)
    cout<<2<<endl;
    else cout<<3<<endl;
    
}




Measured memory_bytes: 3520
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
string s;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>s;ll n =s.size();
		for(ll i=0;i<n;i++)if(s[i]=='?')s[i]='D';
		cout<<s;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 6120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b && b == c) printf("1\n");
    else if (a == b || b == c || c == a) printf("2\n");
    else printf("3\n"); 
    return 0;
}

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

const int N = 100005;
typedef long long i64;
const i64 INF = 1000000007;
typedef long long i64;

i64 a[N];

int main ()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%lld", a + i), a[i] <<= 1;
    sort(a + 1, a + n + 1);
    i64 b = a[n] / 2, mi = INF * 10, p;
    for (int i = 1; i < n; ++i) {
        if (mi > abs(a[i] - b)) mi = abs(a[i] - b), p = a[i];
    }
    printf("%lld %lld\n", a[n] / 2, p / 2);
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

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

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, d; cin >> n >> d;
	int x = 0;
	REP(i, n) {
		int c; cin >> c;
		x ^= (c - 1) % (d + 1);
	}
	if (x == 0)cout << "Second" << endl;
	else cout << "First" << endl;
}


Measured memory_bytes: 3180
N = int(input())
a = list(map(int, input().split()))

b0, b1, b2 = 0,0,0 #b0: 2でも4でも割り切れない b1: 2で割り切れるが4で割り切れない b2: 4で割り切れる

for i in a:
    if i % 2 != 0:
        b0 += 1
    else:
        if i % 4 != 0:
            b1 += 1
        else:
            b2 += 1
            
if b1 == 0:
    if b2 + 1 >= b0:
        print('Yes')
    else:
        print('No')
else:
    b0 += 1
    if b2 + 1 >= b0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <cstdio>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	fast();
	int x, a, b, s, res;

	cin >> x >> a >> b;

	x -= a;
	s = x / b;
	x -= (s*b);
	cout << x << endl;
}

Measured memory_bytes: 256
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let S = get!(String);
    let Q = get!(usize);
    let k = get!(Vec<usize>);

    // D, M, DM の個数を保持しながら数え上げる
    let s = S.chars().collect::<Vec<_>>();
    for K in k {
        let (_, _, _, ans)= (0..N).fold(
            (0, 0, 0, 0),
            |(d, m, dm, dmc), i| {
                let D = (s[i] == 'D') as i64;
                let M = (s[i] == 'M') as i64;
                let C = (s[i] == 'C') as i64;
                if i < K {
                    (
                        d + D,
                        m + M,
                        dm + M * d,
                        dmc + C * dm
                    )
                } else {
                    let D2 = (s[i - K] == 'D') as i64;
                    let d2 = d + D - D2;
                    let dm2 = dm - D2 * m + M * d2;
                    (
                        d2,
                        m + M - ((s[i - K] == 'M') as i64),
                        dm2,
                        dmc + C * dm2
                    )
                }
            }
        );
        println!("{}", ans);
    }
}

Measured memory_bytes: 12532
#include <iostream>
#include <string>

using namespace std;

int main() { 
  string input_str;

  while (getline(cin, input_str)) {
    for (int shift = 0; shift < 26; shift++) {
      for (int str_i = 0; str_i < input_str.size(); str_i++) {
        if (input_str[str_i] >= 'a' && input_str[str_i] < 'z')
          input_str[str_i] ++;
        else if (input_str[str_i] == 'z')
          input_str[str_i] = 'a';
      }
      if (input_str.find("the") != string::npos || input_str.find("this") != string::npos || input_str.find("that") != string::npos)
        break;
    }
    cout << input_str << endl;
  }

  return 0;
}

Measured memory_bytes: 1180