akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 212345;
const ll mod = 1000000007;
int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n*(n+1) >> 1);
}


Measured memory_bytes: 256
#include<algorithm>
#include<stdio.h>
#include<utility>
#include<vector>
#include <math.h>
#include<cmath>
#include <functional>
int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}
void Input(std::vector<std::pair<int ,int> > &vnnInput);
bool bCrossProduct (std::pair<int,int > &point, std::vector<std::pair<int,int> >& StackPoints,int i);
int main(void){
    int nInput;
    scanf("%d",&nInput );
    std::vector<std::pair<int ,int> > vnnInput(nInput);
    Input( vnnInput);
    //vnniValuePoint((angle,lenght_2),n)
    std::vector<std::pair<std::pair<double ,double>,size_t> > vnniValuePoint(nInput);
    vnniValuePoint[0]=std::pair<std::pair<double ,double>,size_t>(std::pair<double ,double>(0.,0.),0);
     for(int i=1;i<nInput;++i ){
        int dX=     vnnInput[i].first-vnnInput[0].first;
        int dY=     vnnInput[i].second-vnnInput[0].second;        
        int nLength_2=dX*dX+dY*dY;
        vnniValuePoint[i].first.second=1.*nLength_2;        
        int GCD=gcd(std::abs(dX),std::abs(dY));
        dX/=GCD;
        nLength_2/=(GCD*GCD);
        vnniValuePoint[i].first.first=std::acos(dX/std::sqrt(1.*nLength_2));
         vnniValuePoint[i].second=i;
    }
     std::stable_sort(vnniValuePoint.begin(),vnniValuePoint.end());
     int n=0;
     for(int i=vnniValuePoint.size()-2;i>=0;--i){
         if(std::abs(vnniValuePoint[vnniValuePoint.size()-1].first.first-vnniValuePoint[i].first.first)>1.e-8){
         break;
         }
         ++n;
     }
     
     std::vector<std::pair<int ,int> > vnnSortedput(nInput);
     for(int i=0;i<nInput;++i){
         vnnSortedput[i]= vnnInput[vnniValuePoint[i].second];
     }
     
    // std::sort(vnnSortedput.end()-n,vnnSortedput.end(),std::greater< std::pair<int ,int> >());
     std::reverse(vnnSortedput.end()-n-1,vnnSortedput.end());
    int iIndex=0;
    for (int i = 1; i <nInput-1 ; ++i){
       vnnInput[++iIndex] = vnnSortedput[i];

         while (!bCrossProduct (vnnSortedput[i+1],vnnInput,iIndex)){
             --iIndex  ;
        }
       
    }
    vnnInput[++iIndex] = vnnSortedput[nInput-1];
    
     
    printf("%d\n",++iIndex);//++??¢???????????????=????´???°

    
    for (int i = 0 ;i < iIndex; ++i){
        printf("%d %d\n",vnnInput[i].first,vnnInput[i].second);
    }
    //system("pause");
    return 0;
}

void Input(std::vector<std::pair<int ,int> > &vnnInput){
    for(int i=0;i<vnnInput.size();++i){
    scanf("%d%d",&vnnInput[i].second,&vnnInput[i].first);
    }
    std::sort(vnnInput.begin(),vnnInput.end());
    for(int i=0;i<vnnInput.size();++i){
    std::swap(vnnInput[i].first,vnnInput[i].second);
    }
}

bool bCrossProduct (std::pair<int,int > &point, std::vector<std::pair<int,int> >& StackPoints,int i){
       
  
    double dValueCrossPro;
   
        dValueCrossPro = 
            (StackPoints[i].first - StackPoints[i-1].first) 
                * (point.second - StackPoints[i].second)
            -(StackPoints[i].second - StackPoints[i-1].second) 
                * (point.first - StackPoints[i].first) ;
        return dValueCrossPro >= 0;
     
}

Measured memory_bytes: 8316
import heapq
def dijkstra_heap(s,node_edges):
    '''
    ノードの入力は0-indexedに修正してから用いる
    returnはノードごとの最小コストを格納したリスト
    '''
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [False] * n #True:未確定
    d[s] = 0
    used[s] = True
    edgelist = []
    # 始点がスタートになってるedgeをヒープキューに追加
    for e in node_edges[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        # ヒープキューからコスト最小のedgeをpop
        minedge = heapq.heappop(edgelist)
        # 該当edgeの行き先が確定済みになってなければこれを通って処理が続く
        if used[minedge[1]]:
            continue
        v = minedge[1]
        # 該当edgeの行き先のコストを更新
        d[v] = minedge[0]
        used[v] = True
        for e in node_edges[v]:
            if not used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

n = int(input())
node_edges = [[] for _ in range(n)]
for i in range(n-1):
    start, end, cost = map(int,input().split())
    start -= 1
    end -= 1
    node_edges[start].append([cost, end])
    node_edges[end].append([cost, start])
num_q, stop = map(int,input().split())
stop -= 1

dist_from_stop = dijkstra_heap(stop, node_edges)
ans_ls = [0] * num_q
for i in range(num_q):
    start, end = map(int,input().split())
    start -= 1
    end -= 1
    ans_ls[i] = dist_from_stop[start] + dist_from_stop[end]
for ans in ans_ls:
    print(ans)



Measured memory_bytes: 56404
while True:
    m, f, r = map(int, input().split())
    mf = m + f
    mfr = m + f + r

    if mfr == -3:
        break
    elif m == -1 or f == -1:
        print('F')
    elif 80 <= mf:
        print('A')
    elif 65 <= mf:
        print('B')
    elif 50 <= mf or 50 <= r:
        print('C')
    elif 30 <= mf:
        print('D')
    elif mf < 30:
        print('F')


Measured memory_bytes: 5592
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase
# def gcd(a,b):
#     if b==0:

#         return a
#     else:
#         return gcd(b,a%b)
def main():
    # mod=10**9+7
    #for _ in range(int(input())):
    n=int(input())
    arr=[int(k) for k in input().split()]
    res=1
    counter=0
    for i in range(n):
        if arr[i]==0:
            counter=1
            print(0)
            break
    if counter==0:
        count=0
        for i in range(n):
            res*=arr[i]
            if res>10**18:
                count=1
                print(-1)
                break
        if count!=1:
            print(res)








BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 95272
N=parse(Int,readline())
s=chomp(readline())
t=chomp(readline())
ans=0
for i=1:N
  flag=true
  for j=1:i
    if s[N-i+j]!=t[j]
      flag=false
    end
  end
  if flag
    ans=i
  end
end
println(2N-ans)

Measured memory_bytes: 108360
#include <stdio.h>
int main(void)
{    
  
  int i,A,B,C,D;
    
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&D);    

  for(i=1;i<=100;i++){
  C=C-B;    
  if(C<=0){
  printf("Yes");
  break;
  }
  A=A-D;
  if(A<=0){
  printf("No");
  break;
  }
  }    
      
   return 0; 
}   
   

Measured memory_bytes: 1736
import numpy as np
s = list(raw_input())
s = [1 if (i == 'A') | (i == 'C') | (i == 'G') | (i == 'T') else 0 for i in s]
s = np.array(s)
count = np.zeros(len(s), dtype=np.int)

if s[0] == 1:
	count[0] = 1
	for i in range(1,len(s)):
		if s[i] == 1:
			count[0] += 1
		else:
			break

for i in range(1,len(s)):
	if (s[i-1] == 0) & (s[i] == 1):
		count[i] = 1
		for j in range(i+1,len(s)):
			if s[j] == 1:
				count[i] += 1
			else:
				break

print max(count)

Measured memory_bytes: 17524
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
const ll M = 1e9 + 7;
vector<int> v[N];
ll dp[N][2];
void dfs(int s, int p){
    dp[s][0] = dp[s][1] = 1;
    for(auto i : v[s]){
        if(i != p){
            dfs(i, s);
            dp[s][0] = (dp[s][0] * dp[i][1]) % M;
            dp[s][1] = (dp[s][1] * ((dp[i][0] + dp[i][1]) % M)) % M;
        }
    }
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 1);
    cout << (dp[1][0] + dp[1][1]) % M;
return 0;
}


Measured memory_bytes: 19584
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

vector<int> prime(int n){
    //n以下の素数をすべて返す
    vector<int> primes;
    for(int i = 2; i <=n; i++)
    {
        int count = 0;
        for(int j = 2; j < i; j++)
        {
            if ( i % j ==0) count++;
        }
        if(count<1){
            primes.push_back(i);
        }
    }
    return primes;
}


int main(){
    int N;cin>>N;
    vector<int>p = prime(N);
    map<int,int> count;
    for(int i = 0; i < p.size(); i++)
    {
        count[p[i]] = 0;
    }
    for(int i = 1; i <= N; i++)
    {
        int tmp = i;
        for(int j = 0; j < p.size(); j++)
        {
            while(tmp%p[j]==0){
                count[p[j]]++;
                tmp = tmp/p[j];
            }
        }
        
    }
    int ans = 0;
    // {4,4,2},{24,2},{14,4},{74}のときに75ことなる
    vector<int> v_req = {2,4,14,24,74};
    map <int,int> m_required;
    REP(i,p.size()){
        REP(j,v_req.size()){
            if( count[p[i]]>= v_req[j]){
                m_required[v_req[j]]++;
            }
        }
    }
    ans += m_required[4] * (m_required[4]-1) * (m_required[2]-2)/2;
    ans += m_required[24] * (m_required[2]-1);
    ans += m_required[14] * (m_required[4]-1);
    ans += m_required[74];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

namespace {

struct Node {
  size_t x;
  Node* next;
  Node* prev;
};

class List {
 public:
  List() : first_(NULL), last_(NULL) {}
  ~List() {
    Node* n = first_;
    while (n != NULL) {
      Node* cur = n;
      n = cur->next;
      delete cur;
    }
  }

  void Print() const {
    for (Node* n = first_; n; n = n->next) {
      if (n != first_) printf(" ");
      printf("%lu", n->x);
    }
    printf("\n");
  }

  void Insert(size_t x) {
    if (!first_) {
      Node* n = new Node;
      n->x = x;
      n->next = NULL;
      n->prev = NULL;
      first_ = n;
      last_ = n;
      return;
    }

    Node* n = new Node;
    n->prev = NULL;
    n->x = x;
    n->next = first_;
    first_->prev = n;
    first_ = n;
  }

  void Delete(size_t x) {
    for (Node* n = first_; n; n = n->next) {
      if (n->x != x) {
        continue;
      }
      if (n == first_) {
        DeleteFirst();
        break;
      }
      if (n == last_) {
        DeleteLast();
        break;
      }
      Node* prev = n->prev;
      Node* next = n->next;
      prev->next = next;
      // Last node
      if (next) {
        next->prev = prev;
      } else {
        last_ = prev;
      }
      delete n;
      break;
    }
  }

  void DeleteFirst() {
    if (!first_) {
      return;
    }
    Node* next = first_->next;
    delete first_;
    first_ = next;
    if (next) {
      next->prev = NULL;
    } else {
      last_ = NULL;
    }
  }

  void DeleteLast() {
    if (!last_) {
      return;
    }
    Node* prev = last_->prev;
    delete last_;
    last_ = prev;
    if (prev) {
      prev->next = NULL;
    } else {
      first_ = NULL;
    }
  }

 private:
  Node* first_;
  Node* last_;
};

} // namespace

int main() {
  int n;
  cin >> n;

  char b[16];
  string op;
  op.reserve(16);
  size_t x = 0;

  List list;
  for (int i = 0; i < n; ++i) {
    scanf("%s", b);
    op = b;

    if (op == "insert") {
      scanf("%lu", &x);
      list.Insert(x);
    } else if (op == "delete") {
      scanf("%lu", &x);
      list.Delete(x);
    } else if (op == "deleteFirst") {
      list.DeleteFirst();
    } else {
      list.DeleteLast();
    }
  }
  list.Print();
  return 0;
}

Measured memory_bytes: 32452
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

move = [abs(a[i - 1] - a[i]) for i in range(1, n + 2)]
msum = sum(move)
for i in range(1, n + 1):
    tmp = - move[i - 1] - move[i] + abs(a[i - 1] - a[i + 1])
    print(msum + tmp)


Measured memory_bytes: 14176
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll r=0,M=-1,res,N,C,tl[31][200001],s,t,c;
  REP(j,31){
    REP(i,200001){
      tl[j][i] = 0;
    }
  }
  cin >> N >> C;
  REP(i,N){
    cin >> s >> t >> c;
    c--;
    tl[c][2*s-1] += 1;
    tl[c][2*t] += -1;
  } 
  REP(i,C){
    r = 0;
    REP(j,200001){
      r += tl[i][j];
      tl[i][j] = r;
      if(tl[i][j] == 2)
        tl[i][j] = 1;
    }
  }

  REP(j,200001){
    r = 0;
    REP(i,C)
      r += tl[i][j];
    res = max(r,res);
  }
  
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

int main()
{
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	const double pi=3.14159265358979;

	double radh, radm, xh, yh, xm, ym, d;
	radh=(h+m/(double)60)/12*2*pi;
	radm=m/(double)60*2*pi;
	xh=a*sin(radh);
	yh=a*cos(radh);
	xm=b*sin(radm);
	ym=b*cos(radm);
	d=sqrt((xh-xm)*(xh-xm)+(yh-ym)*(yh-ym));
	cout << setprecision(15) << d << endl;
}







Measured memory_bytes: 4164
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007;
#define INF 10*12;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N;cin>>N;
  vector<vector<int>> input(2*N,vector<int>(50,0));
  string S;
  REP(i,0,N){
    cin>>S;
    REP(j,0,S.size()){
      int c=(int)S.at(j)-'a';
      input[i][c]++;
    }
  }
  string ans="";
  REP(j,0,50){
    char target_c=(char)j+'a';
    int min_=INF;
    REP(i,0,N){
      min_=min(min_,input[i][j]);
    }
    REP(i,0,min_){
      ans+=target_c;
    }
  }

  print(ans)

}


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


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var arr = Console.ReadLine().Split(' ');
        var list = new List<double>();

        foreach (var v in arr)
        {
            list.Add(double.Parse(v));
        }

        while (list.Count > 1)
        {
            var v1 = list.Min();
            list.Remove(v1);
            var v2 = list.Min();
            list.Remove(v2);

            var v3 = (v1 + v2) / 2;
            list.Add(v3);
        }

        var ret = list[0];
        Console.Write(ret);
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  ll A,B,C,K; cin>>A>>B>>C>>K;
  ll ans=min(A,K);
  K-=min(A,K);
  if(K>0){
    K-=min(K,B);
  }
  if(K>0){
    ans-=min(K,C);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    int n;cin >>n;
    long long arr[3*n];
    fo(i,3*n){
        cin >> arr[i];
    }
    sort(arr,arr+(3*n));
    long long ans = 0;
    for(int j = 1;j<=n;++j){
        ans += arr[(3*n)-(2*j)];
    }
    cout << ans;
}

Measured memory_bytes: 5936
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
string s;
int res[256], cnt[256];
 
int main(int argc, char **argv) {
	cin >> n;
	REP(i, 256) res[i] = 50;
	REP(i, n) {
		cin >> s;
		CLEAR(cnt);
		REP(j, s.length()) ++cnt[s[j]];
		REP(j, 256) res[j] = min(res[j], cnt[j]);
	}
	REP(i, 256) REP(j, res[i]) cout << ((char)i);
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
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<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=1000001;
int n;
bool a[M];

int main(){
	cin>>n;
	a[n]=1;
	for(int i=2;;i++){
		if(n%2==0) n/=2;
		else n=3*n+1;
		if(a[n]){
			cout<<i<<endl;
			break;
		}
		a[n]=1;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cfenv>

using namespace std;

double distance(vector<int> x, vector<int> y, int d)
{
    double dist = 0;
    for (int i = 0; i < d; i++) {
        dist += (x[i] - y[i]) * (x[i] - y[i]);
    }
    return sqrt(dist);
}

int main()
{
    int N, D;
    cin >> N >> D;

    vector<vector<int> > X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    double dist = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            dist = distance(X[i], X[j], D);
            if (ceil(dist) == floor(dist)) {
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
using System.Text;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[m];
        var b = new int[m];
        var p1 = 0L;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]);
            b[i] = int.Parse(line[1]);
            p1 += (a[i] + 1) % b[i];
        }
        var c = getAns(a, b, n, m);
        print(c, p1, n, m);
    }
    static void print(long[] c, long p1, int n, int m)
    {
        var sb = new StringBuilder();
        var w1 = p1 + c[1];
        sb.Append(string.Format("{0}\n", w1));
        for (int i = 2; i <= n; i++)
        {
            c[i] = c[i - 1] + c[i];
            var w = p1 + c[i] + m * (long)(i - 1);
            sb.Append(string.Format("{0}\n", w));
        }
        Console.Write(sb);
    }
    static long[] getAns(int[] a, int[] b, int n, int m)
    {
        var c = new long[n + 1];
        for (int i = 0; i < m; i++)
        {
            var bi = b[i];
            var p = bi - a[i];
            while (p <= n)
            {
                if (p != 1) c[p] -= bi;
                p += bi;
            }
        }
        return c;
    }
}



Measured memory_bytes: 28628
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

	int n = nextInt();
    
    String[] s = splitString(next());
    
    int cnt = 0;
    int ans = 0;
    
    for(int i=0;i<n-2;i++){
		if(s[i].equals("A") && s[i+1].equals("B") && s[i+2].equals("C")){ans++;}
    }
    
    System.out.println(ans);
      
  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 21972
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let number: i32 = read();
    let mut takoyaki: Vec<i32> = read_vec();

    let mut recovery_value: i32 = 0;

    loop
    {
        let parent_number = takoyaki[0];
        takoyaki.remove(0);
        if takoyaki.len() <= 0 { break; }

        for value_of_takoyaki in &takoyaki
        {
            recovery_value += value_of_takoyaki * parent_number;
        }
    }

    println!("{}", recovery_value);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    double x,y;
    double X,Y;
    double a,b,c,d,e,f;
    
    while(scanf("%lf",&a)!=EOF){
        scanf("%lf %lf %lf %lf %lf",&b,&c,&d,&e,&f);
        X=(e*c-b*f)/(a*e-b*d);
        Y=(a*f-d*c)/(a*e-b*d);
        if(X>=0){
            X=(int)(1000*X+0.5);
        }else{
            X=(int)(1000*X-0.5);
        }
        
        if(Y>=0){
            Y=(int)(1000*Y+0.5);
        }else{
            Y=(int)(1000*Y-0.5);
        }
       
      
        x=(double)X/1000;
        y=(double)Y/1000;
        
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;       
}
    



Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
    long long int n,k;
    cin>>n>>k;

    vector< pair<long long int,long long int> > a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        cin>>a[i].second;
    }
    pair<long long int,long long int> temp;
    sort(a.begin(),a.end());

    long long int hoge=0;
    for(int i=0;;i++){
        hoge+=a[i].second;
        if((k<=hoge)){
            cout<<a[i].first<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  
  int a,b,c;
  int i;
  int t = 0;
  int total = 0;
  
  scanf("%d %d %d",&a,&b,&c);
    
  while(1){
    for(i=0;i<a;i++){
      total++;

      if(total == 60*t+c){
	printf("%d\n",total);
	return 0;
      }
      
      if(total == 60*(t+1))
      t++;

    }
    
    for(i=0;i<b;i++){
      total++;
      
      if(total == 60*(t+1)){
	if((60*(t+1))%(a+b) == 0){
	  puts("-1");
	  return 0;
	}
	else
	  t++;
      }
    }
  }
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5;
    
     int mod= 998244353;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};  
    
	 
 
     void solve(){
          int n,k,ct=0;
          cin>>n>>k;
          while(n>0) {
			      n/=k;
			      ct++;	      
			  }
			  cout<<ct<<endl;
       	    
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int height[200][200];
int top[200][200];
int cnt[11];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int nei[10][10] = {{}, 
  {3, 5, 4, 2}, 
  {3, 1, 4, 6}, 
  {5, 1, 2, 6}, 
  {1, 5, 6, 2}, 
  {1, 3, 6, 4}, 
  {5, 3, 2, 4}, 
};


void Construct(vector<int> &num, int t, int f) {
  num[4] = t;
  num[5] = 7-t;
  num[1] = f;
  num[3] = 7-f;
  
  rep(idx, 4) { 
    if (nei[t][idx] == f) {
      num[2] = nei[t][(idx+1)%4];
      num[0] = nei[t][(idx+3)%4];
      break;
    }
  }
}

void Roll(vector<int> &num, int idx) {
  vector<int> ret(6);
  ret[(idx+1)%4] = num[(idx+1)%4];
  ret[(idx+3)%4] = num[(idx+3)%4];
  ret[5] = num[idx];
  ret[(idx+2)%4] = num[5];
  ret[4] = num[(idx+2)%4];
  ret[idx] = num[4];
  num = ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  while (1) {
    cin >> N;
    if (!N) return 0;

    fill(height[0], height[200], 0);
    fill(top[0], top[200], -1);
    rep(i, N) {
      int x = 100;
      int y = 100;

      int t, f;
      cin >> t >> f;
      vector<int> num(6);
      Construct(num, t, f);

      while (1) {
        pii mv(-1, -1);
        rep(i, 4) {
          int nx = x + dx[i];
          int ny = y + dy[i];
          if (height[ny][nx] >= height[y][x]) continue;
          if (num[i] <= 3) continue;
          MX(mv, pii(num[i], i));
        }

        if (mv.X == -1) {
          height[y][x]++;
          top[y][x] = num[4];
          break;
        }
        x += dx[mv.Y];
        y += dy[mv.Y];
        Roll(num, mv.Y);
      }
    }

    fill(cnt, cnt+10, 0);
    rep(y, 200) {
      rep(x, 200) {
        if (top[y][x] == -1) continue;
        cnt[top[y][x]]++;
      }
    }

    reps(i, 1, 7) {
      if (i > 1) cout << " ";
      cout << cnt[i];
    }
    cout << "\n";
  }
}



Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

signed main(){
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			int k=n-i-j;
			if(10000*i+5000*j+1000*k==y && k>=0){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();

    public void run() {
    	int n=sc.nextInt();
    	TCase:while(n--!=0){
    		char[] key=sc.next().toCharArray();
    		char[] str=sc.next().toCharArray();
    		for(int i=key.length-1;i>=0;i--){
    			switch(key[i]){
	    			case 'C':{
	    				char tmp=str[0];
	    				for(int s=0;s+1<str.length;s++){
	    					str[s]=str[s+1];
	    				}
	    				str[str.length-1]=tmp;
	    				break;
	    			}case 'J':{
	    				char tmp=str[str.length-1];
	    				for(int s=str.length-1;s>=1;s--){
	    					str[s]=str[s-1];
	    				}
	    				str[0]=tmp;
	    				break;
	    			}case 'E':{
	    				char[] tmp=Arrays.copyOf(str,str.length);
	    				for(int s=0;s<str.length/2;s++){
	    					str[s]=tmp[s+(1+str.length)/2];
	    				}
	    				for(int s=0;s<str.length/2;s++){
	    					str[s+(1+str.length)/2]=tmp[s];
	    				}
	    				break;
	    			}case 'A':{
	    				char[] tmp=Arrays.copyOf(str,str.length);
	    				for(int s=0;s<str.length;s++){
	    					str[s]=tmp[str.length-1-s];
	    				}
	    				break;
	    			}case 'M':{
	    				for(int s=0;s<str.length;s++){
	    					if(Character.isDigit(str[s]))
	    						str[s]=(char) (((str[s]-'0')+1)%10+'0');
	    				}
	    				break;
	    			}case 'P':{
	    				for(int s=0;s<str.length;s++){
	    					if(Character.isDigit(str[s]))
	    						str[s]=(char) (((str[s]-'0')-1+10)%10+'0');
	    				}
	    				break;
	    			}
    			}
    		}
    		ln(new String(str));
    	}
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

Measured memory_bytes: 17192
int main() {
int N;
scanf("%d",&N);
int a[N+1];
int count=0;
for(int i=0;i<N;i++){
  scanf("%d",&a[i]);
}
 for(int j=0;a[j]!='\0';j++){
 if(a[j]%2==1&&j%2==0){
   count++;
 }
 }
printf("%d",count);
}


Measured memory_bytes: 1688
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
N = str(N)
for i in range(3):
    if N[i] == '7':
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 82300
/* ITP1_9_A */
#include <stdio.h>
#include <string.h>

#define MAX_LINE_LENGTH 1001
#define END_TEXT_LENGTH 13
#define MATCHED 1
#define UN_MATCHED 0
#define TOGGLING 32
#define CHAR_CODE_SMALL_A 97
#define CHAR_CODE_SMALL_Z 122

/* ?????????????????¢??° */
void array_init(char char_array[]);
/* ??????????????´???????????????????¢????????????¢??° */
short is_matches(char sentence[], char word[]);
/* ?°????????????§??????????????? */
void to_upper_case(char word[], char result[]);
int main(void)
{
	char target_word[MAX_LINE_LENGTH];
	array_init(target_word);

	// ????´¢????±???????????????\???
	scanf("%s", target_word);
	
	char input_line[MAX_LINE_LENGTH];
	
	short count = 0;
	
	// ????´¢?????????????????\???
	while(1)
	{
		array_init(input_line);
		scanf("%s", input_line);
		if( is_matches(input_line, target_word) )
		{
			count++;
		}
		if( NULL != strstr(input_line, "END_OF_TEXT") )
		{
			break;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

/* ?????????????????¢??° */
void array_init(char char_array[])
{
	short ii;
	for( ii = 0; ii < MAX_LINE_LENGTH; ii++ )
	{
		char_array[ii] = '\0';
	}
}

/* ??????????????´???????????????????¢????????????¢??° */
short is_matches(char sentence[], char word[])
{
	
	char sentence_large[MAX_LINE_LENGTH];
	array_init(sentence_large);
	to_upper_case(sentence, sentence_large);
	
	char word_large[MAX_LINE_LENGTH];
	array_init(word_large);
	to_upper_case(word, word_large);
	
	char *search_result = strstr(sentence_large, word_large);
	
	if( 0 == strcmp(sentence_large, word_large) )
	{
		return MATCHED;
	}
	else
	{
		return UN_MATCHED;
	}
//	if( NULL != strstr(sentence_large, word_large) )
//	{
//		return MATCHED;
//	}
//	else
//	{
//		return UN_MATCHED;
//	}
}

/* ?°????????????§??????????????? */
void to_upper_case(char word[], char result[])
{
	short length = strlen(word);
	short ii;
	for( ii = 0; ii < length; ii++ )
	{
		if( CHAR_CODE_SMALL_A <= word[ii] && word[ii] <= CHAR_CODE_SMALL_Z )
		{
			result[ii] = word[ii] - TOGGLING;
		}
		else
		{
			result[ii] = word[ii];
		}
	}
}

Measured memory_bytes: 564
n = int(input())
l = list()
for i in range(120):
	l.append(0)
for i in range(n):
	b, f, r, v = map(int, input().split())
	l[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
	if i >= 1:
		print('#' * 20)
	for j in range(3):
		for k in range(10):
			print(' ', end='')
			print(l[i * 30 + j * 10 + k], end='')
		print()


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}

int main(){
	string s;
	cin>>s;
	ll ans = 0;
	ll flag=0;
	if(s[0]=='R') flag=1;
	rep(i,1,3){
		if(s[i]==s[i-1] && s[i]=='R') ans++;
		if(s[i]=='R') flag=1;
	}
	if(flag) cout<<ans+1;
	else cout<<0;
	
}
		 

Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn is_integer(f: f64) -> bool {
    f - f.floor() == 0.0
}

fn main() {
    input! {
        x: i64,
    }
    for a in -1000..1001 {
        for b in -1000..1001 {
            if (a as i64).pow(5) - (b as i64).pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


Measured memory_bytes: 2084
#include<stdio.h>
int main()
{
     int a,b,c;
     scanf("%d%d%d",&a,&b,&c);
     if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))
          printf("YES");
     else
          printf("NO");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  string S;
  cin >> S;
  vector<ll> a(S.size()+1);
  if(S.at(0) == '<') a.at(0) = 0;
  
  ll i = 0; ll j = 0;
  ll count = 0;
  while(i < S.size()){
    if(S.at(i) == '<'){
      a.at(i) = 0;
      while(S.at(i) == '<'){
        a.at(i+1) = a.at(i) + 1;
        i++;
        if(i == S.size()) {
          break; break;
        }
      }
    }else{
      count = 0; j = i;
      while(S.at(j) == '>') {
        count++; 
        j++;
        if(j == S.size()) break;
      }
      if(count > a.at(i)) {
        a.at(i) = count;
        a.at(i+1) = count -1;
      }else{
        a.at(i+1) = count -1;
      }
      j=i+1;
      while(j <= (i+count-1)){
        a.at(j+1) = a.at(j) - 1; 
        j++;
        if(j == S.size()) {
          break; 
          break;
        }
      }
      i=j;
      //cout << "i " << i << " count " << count << endl;
    }
  }
  
  ll Sum = 0;
  rep(i, S.size()+1) Sum += a.at(i);
  
  //rep(i, S.size()) cout << a.at(i) << S.at(i);
  //cout << a.at(S.size());
  //cout << endl;
  cout << Sum;
  
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int mat[21][21];
ll pat[1<<21];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(y,N) FOR(x,N) cin>>mat[y][x];
	
	
	pat[0]=1;
	for(int mask=0;mask<1<<N;mask++) {
		y=__builtin_popcount(mask);
		FOR(x,N) if((mask&(1<<x))==0 && mat[y][x]) (pat[mask | (1<<x)]+=pat[mask])%=mo;
	}
	cout<<pat[(1<<N)-1]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

intt a, b, n;

int main() {

	FAST;

	cin >> a >> b >> n;
	intt x = min(b - 1, n);
	cout << a * x / b << '\n'; 
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    long long cnt = 0, ans = 0;
    ans += min(A, K);
    cnt += min(A, K);
    if(cnt == K){
        cout << ans << endl;
        return 0;
    }
    cnt += min(B, K - cnt);
    if(cnt == K){
        cout << ans << endl;
        return 0;
    }
    ans -= min(C, K - cnt);
    cnt += min(C, K - cnt);
    cout << ans << endl;
}

Measured memory_bytes: 3636
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
 
signed main(void)
{
	int n, m, c;
	cin >> n >> m >> c;
	if(n <= c && c <= m) cout << "Yes" << endl;
	else cout << "No" << endl;
 
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  vector<int>a(N);
  a.at(N-1)=-1;
  for(int i=N-1;i>0;i--){
    if(data.at(i-1)>data.at(i)) a.at(i-1)=-1;
    else if(data.at(i-1)<data.at(i)) a.at(i-1)=1;
    else a.at(i-1)=a.at(i);
  }
  int64_t K=0,M=1000,Z=0;
  for(int i=0;i<N;i++){
    if(a.at(i)==1&&Z>=0&&M>=data.at(i)){
      K=M/data.at(i);
      M%=data.at(i);
      Z=-1;
    }
    else if(a.at(i)==-1&&Z<=0&&K>0){
      M+=K*data.at(i);
      K=0;
      Z=1;
    }
  }
  cout << M << endl;
}

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

int A[60],B[60];

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int main(){
	int N;
	for(int i=1;i<=50;i++){
		cin>>A[i]>>B[i];
		if(cin.eof()){
			N=i-1;
			break;
		}
	}
	int res[2];
	for(int i=1;i<=N;i++){
		res[0]=gcd(A[i],B[i]);
		res[1]=A[i]/res[0]*B[i];
		cout<<res[0]<<" "<<res[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
from sys import stdin
from fractions import gcd
def main():
    readline=stdin.readline
    n,x=map(int,readline().split())
    a=list(map(int,readline().split()))

    for i in range(n):
        if i==0:
            ans=abs(x-a[i])
        else:
            ans=gcd(ans,abs(x-a[i]))

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 16280
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	vector<int> t(N);
	int an = 0;
	for (int i = 0; i < N; i++) {
		cin >> s.at(i)>>t.at(i);
		an += t.at(i);
	}
	string X;
	cin >> X;
	
	int i = 0;
	while (s.at(i) != X) {
		an -= t.at(i);
		i++;
	}
	an -= t.at(i);
	cout <<an<< endl;
}

Measured memory_bytes: 256
import itertools

def main():
    n,m,q = tuple([int(t)for t in input().split()])

    a = [[int(t)for t in input().split()]for _ in [0]*q]
    
    ans = []
    for lst in itertools.combinations_with_replacement(range(1,m+1),n):
        t = 0
        for a_i,b_i,c_i,d_i in a:
            t +=  d_i if lst[b_i-1]-lst[a_i-1]==c_i else 0
        ans.append(t)
    
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 12764